How do i simply change a sprite's image in cocos2d?

后端 未结 7 1294
逝去的感伤
逝去的感伤 2021-02-14 18:28

I\'ve tried

[[CCTextureCache sharedTextureCache] addImage: @\"still.png\"];

But I always end up with a distorted image for some reason. It\'s m

7条回答
  •  鱼传尺愫
    2021-02-14 18:48

    This is the most straight forward way to change the image of a sprite(if you have it loaded trough a spritesheet) this definitely works (I use it all the time in my game). mySprite is the name of the sprite instance:

    [mySprite setDisplayFrame:
    [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: @"sprite1.png"] ];

提交回复
热议问题