在运行时更改CCSprite映像

时间:2012-01-20 07:41:07

标签: iphone cocos2d-iphone

需要在运行时更改CCSprite图像,我必须删除以前加载的图像并在NSTimer的特定内部之后显示新图像,我正在使用[imagesContainer removeChildByTag:0 cleanup:YES];但不能正常工作< / p>

任何帮助都将受到高度赞赏

1 个答案:

答案 0 :(得分:0)

你可以删除像你正在做的精灵并添加一个新的精灵但记得用addChild将它添加到图层中:

 CCSprite *theNewSprite = [CCSprite spriteWithFile:@"newImage.png"];
 [LayerYouWantToAdd addChild:theNewSprite]

或者只是改变精灵的纹理。这对我有用。

[theSprite setTexture:[[CCSprite spriteWithFile:@"newImage.png"]texture]];
相关问题