开发者

create a texture from a spritesheet cocos2d

Hey all Basically all i want is to create CCTe开发者_开发问答xture2D objects from a spritesheet. I can make individual sprites from

charSpriteCur = [CCSprite spriteWithTexture:charSheet.texture rect:CGRectMake(136, 0, 136, 223)];

but i want to get individual textures from a spritesheet so that i can use

[mySprite setTexture:tex]; to change the sprite as required. I dont need it to be an animated sprite i just want to be able to change its texture when i want using a spritesheet. any ideas with this or what is the best approach? thanks g


I don't think this is possible. When I need to do this I instead remove the CCSprite node (which I have setup as a property in my class) and then make a new one. Here is an example:

[self removeChild:[self mySprite] cleanup:YES];
[self setMySprite:[CCSprite spriteWithSpriteFrameName:@"image.png"]];
[mySprite setAnchorPoint:ccp(0,1)];
[mySprite setPosition:ccp(623,872)];
[self addChild:mySprite z:5];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜