本文介绍了如何在cocos2d中简单地更改sprite的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试过
[[CCTextureCache sharedTextureCache] addImage:@still.png];
但是我总是因为某种原因而导致失真的图像。这很可能是因为我的图片不是相同的分辨率,但对于这个应用程序,他们不能有相同的res。
解决方案
<$ p如何更改sprite的图像,而不必执行复杂的制作spritesheet或动画的过程。 $ p> urSprite = [CCSprite spriteWithFile:@one.png];
urSprite.position = ccp(240,160);
[self urSprite z:5 tag:1];
//改变相同sprite的图像
[urSprite setTexture:[[CCTextureCache sharedTextureCache] addImage:@two.png]];
I've tried
[[CCTextureCache sharedTextureCache] addImage: @"still.png"];
But I always end up with a distorted image for some reason. It's most likely because my images are not the same resolution, but for this app, they can't have the same res. How do I change the sprite's image without going through the complicated process of making a spritesheet or an animation or any of that.
解决方案
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"]];
这篇关于如何在cocos2d中简单地更改sprite的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!