Iphone 如何为CCSprite应用动画
我刚刚开始了一个cocos2d游戏。在该游戏中,我正在检查碰撞,如果发生碰撞,请使用以下代码创建动画。调用动画代码,但不显示任何动画。这有什么错误。请帮助我解决Iphone 如何为CCSprite应用动画,iphone,cocos2d-iphone,game-physics,ccsprite,Iphone,Cocos2d Iphone,Game Physics,Ccsprite,我刚刚开始了一个cocos2d游戏。在该游戏中,我正在检查碰撞,如果发生碰撞,请使用以下代码创建动画。调用动画代码,但不显示任何动画。这有什么错误。请帮助我解决 -(void)check_collision:(ccTime)dt { for(PolygonSprite *sprite in _cache) { if(CGRectIntersectsRect(sprite.boundingBox,monkey.boundingBox)) { if(sprite
-(void)check_collision:(ccTime)dt
{
for(PolygonSprite *sprite in _cache)
{
if(CGRectIntersectsRect(sprite.boundingBox,monkey.boundingBox))
{
if(sprite != monkey)
{
NSLog(@"collision collision collision.......%@",sprite);
id s2 = [CCScaleTo actionWithDuration:0.5 scaleX:1.5 scaleY:1.5];
id fun = [CCCallFuncN actionWithTarget:self selector:@selector(spriteDone:)];
[sprite runAction:[CCSequence actions:s2,fun,nil]];
[self unschedule:@selector(check_collision:)];
}
}
}
}试试这个
[self schedule:@selector(check_collision:)interval:1];
-(void) check_collision: (ccTime) t
{
for(PolygonSprite *sprite in _cache)
{
if(CGRectIntersectsRect(sprite.boundingBox,monkey.boundingBox))
{
if(sprite != monkey)
{
id s2 = [CCScaleTo actionWithDuration:0.1 scaleX:2 scaleY:2];
id fun = [CCCallFuncN actionWithTarget:self selector:@selector(spriteDone)];
[car.sprite runAction:[CCSequence actions:s2,fun,nil]];
[self unschedule:@selector(check_collision:)];
}
}
}
}
-(void) spriteDone
{
// Function logic goes here..
}
希望这有帮助。。谢谢你你检查过代码的每一行都被执行了吗?是的。我放了断点并检查了它。在我身边工作正常。试着在计划外发表评论。@HaveToLearnMore这与你正在做的不同。显示spriteDone的代码。。。