3
我是Cocos2D的新手。我正在为iPhone制作一个简单的游戏,我希望我的精灵在一些动画中消失。到目前为止我可以把它用下面的代码消失: -如何通过点击各种动画使精灵消失?
-(void)selectSpriteForTouch:(CGPoint)touchLocation
{
for (CCSprite *sprite in targets)
{
if (CGRectContainsPoint(sprite.boundingBox, touchLocation))
{
NSLog(@"sprite was touched");
[sprite.parent removeChild:sprite cleanup:YES];
[[SimpleAudioEngine sharedEngine] playEffect:@"pop.wav"];
[[SimpleAudioEngine sharedEngine] setEffectsVolume:4.0f];
}
}
}
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for(UITouch *touch in touches)
{
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sharedDirector] convertToGL: location];
[self selectSpriteForTouch:location];
NSLog(@"touch was detected");
}
}
现在我想精灵与一些动画或任何效果消失。我该怎么做?
感谢James,您的建议很有帮助。具体来说,我正在构建一个应用程序,在触摸时气球爆炸。我想要一种爆炸效果或者看起来更合适的东西。 –
您可能想要使用一系列帧来实现爆炸动画。查看[CCAnimation](http://www.cocos2d-iphone.org/api-ref/0.99.5/interface_c_c_animation.html)的编码和[Zwoptex](http://zwoptexapp.com/)创建spritesheet。 –