您的位置:首页 > 移动开发 > Cocos引擎

cocos2d - Changing the image of a CCSprite

2013-12-05 16:47 274 查看
CCTexture2D* tex = [[CCTextureCache sharedTextureCache] addImage:@"new_image_name"];
[spriteWant2Change setTexture: tex];


what to do if texture is different in size from previous one ?

If the sprites are of different size then you will need to do this after calling setTexture function

[spriteWant2Change setTextureRect:CGRectMake(0, 0, tex.contentSize.width, tex.contentSize.height)];


摘自:Stack Overflow
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: