如何调用具有多个参数的方法
你好,我是 iOS 开发新手,我有一个简单的问题。
我不知道如何调用以下方法。
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//do something here
}
但是当我使用时
[self ccTouchesBegan]
出现错误并且不起作用。 我知道这是一个非常简单的问题,但我自己无法解决,
谢谢。
hi I'm new to iOS development and i have a simple question.
I don't know how to call the following method.
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//do something here
}
But when I use
[self ccTouchesBegan]
I get an error and it doesn't work.
I know this is really simple question but I can't figure it out by myself
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这些是委托方法。您不应手动调用它。
更重要的是你没有给它正确的arg对象。
你一直在使用cocos2d
阅读它并明确
http://www.cocos2d -iphone.org/wiki/doku.php/tips:touchdelegates
those are delegate methods.u should not call it manually.
more over u didn't give correct arg objects to it.
u have been using cocos2d
read it and make clear
http://www.cocos2d-iphone.org/wiki/doku.php/tips:touchdelegates
你不用调用 -ccTouchesBegan:withEvent: —— cocos2d 会帮你调用它。您所要做的就是定义您自己的版本来处理触摸的开始。阅读更多介绍性示例,您就会了解它是如何使用的。例如,如何制作Simple iPhone Game with Cocos2D 使用touchesEnded,但原理是一样的。
You don't call -ccTouchesBegan:withEvent: -- cocos2d calls it for you. What you have to do is define your own version of it to process the beginning of a touch. Read a little more introductory examples and you'll see how it's used. For instance, How To Make A Simple iPhone Game with Cocos2D uses touchesEnded, but it's the same principle.
您缺少该方法的其余部分。你应该这样做:
yourTouch 类型为
(NSSet*)
, yourEvent 类型为(UIEvent*)。
You are missing the rest of the method. You should do something like this:
Being yourTouch of the type
(NSSet*)
and yourEvent of the type(UIEvent*
).