Changing the image of a CCSprite

后端 未结 11 1979
离开以前
离开以前 2020-12-24 12:12

I have created a number of CCSprites using spriteWithFile.

How do I change the image for the sprite during runtime?

I need to change a few sprites images qui

11条回答
  •  别那么骄傲
    2020-12-24 12:41

    you need to make one cctexture2d object in such a way

    CCTexture2D* newtexture = [[CCTextureCache sharedTextureCache] addImage:@"new-texture"]; [mainSprite setTexture: newtexture];

    this is a whole thing needed to be done if you want change sprite image texture run time.

提交回复
热议问题