iphone - how to apply animation for CCSprite -
am started 1 cocos2d game.in checking collision , if collision occurs creating animation using following code.animation code called not showing animation.what error this.please me solve.
-(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:)]; } } }
}
try this,
[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.. }
hope helps.. thank you
Comments
Post a Comment