Cocos2d 游戏中的碰撞检测?
问题描述
我正在尝试通过以下方式检测两个精灵的碰撞...但是当我尝试运行游戏时没有发生碰撞......什么我可能做错了吗?
i am trying to detect Collision of two sprites in the following way...but when i try to run the game no collision takes place.... what am i possibly doing wrong??
}
projectile 精灵从屏幕顶部到底部动画,monkey 精灵在底部从左到右动画 弹丸穿过猴子,但日志确实不被叫???
projectile sprite is animating from top of screen to the bottom and monkey sprite is animating from left to right at the bottom the projectile goes through the monkey but the log does not get called???
}
-(void)spriteMoveFinished:(id)sender {
-(void)spriteMoveFinished:(id)sender {
}
-(void)addTarget {
-(void)addTarget {
}
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
}
-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
}
推荐答案
你应该使用内置功能:
boundingBox 方法考虑了更多的事情,例如,如果节点相对于其父节点定位.
The boundingBox method takes a couple more things into account, for example if the node is positioned relative to its parent.
另外请注意,在 Objective-C 中使用下划线作为变量前缀被认为是不好的做法.Apple 为其内部库保留带有前导下划线的变量名称.如果确实需要对实例变量进行分类,一种常见的方法是在它们后面加上下划线.
Also note that prefixing variables with an underscore is considered bad practice in Objective-C. Apple reserves variable names with leading underscores for their internal libraries. If you really need to classify instance variables, one common way is to suffix them with an underscore.
这篇关于Cocos2d 游戏中的碰撞检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!