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

后端 未结 7 1302
逝去的感伤
逝去的感伤 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:44

    urSprite = [CCSprite spriteWithFile:@"one.png"];
    urSprite.position = ccp(240,160);
    [self urSprite z:5 tag:1];
    
    // Changing the image of the same sprite
    [urSprite setTexture:[[CCTextureCache sharedTextureCache] addImage:@"two.png"]];
    

提交回复
热议问题