在运行时更改CCSprite映像



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

任何帮助都将不胜感激

您可以像现在这样删除精灵并添加一个新的精灵,但请记住使用addChild:将其添加到层中

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

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

[theSprite setTexture:[[CCSprite spriteWithFile:@"newImage.png"]texture]];

最新更新