IOS and Cocos2d - CCSprite Image Change And New Dimensions = FAIL

One of the bonuses in my game is reducing the size of the main sprite. So for the sake of memory, instead of looping sprite.scale through each frame, I saved the sprite at a percentage size below the original sprite and just want to replace it. Then, when "death" occurs or the timeout expires, the original sprite is returned.

So, I use this code to make it small:

[player setTexture:[[CCTextureCache sharedTextureCache] addImage:@"player-small.png"]];

and this code to return to normal:

[player setTexture:[[CCTextureCache sharedTextureCache] addImage:@"player-orig.png"]];

however, the orignal image (in both init and reset) looks fine. But when I change it to a new sprite (the size of which is exactly 75% of the original), it changes it, but displays only the quadrant of the new sprite, but with the original dimensions.

I tried changing sprite.contentsize before the sprite retexture, but all that was done was to resize, but not affect the problem with the image starting up.

Here are some good examples:

Original:

Original


Retextured Image with contentSize modification:

Retextured Image with contentSize modification


The returned image to the original image with contentSize does not reset (oops, but this is not a problem at all - I just forgot to read the size code):

Retexted image to the Original image with the contentSize not reset properly (oops, but this isn't a problem at all - i just forgot to readd the size code):

PS - I have versions of "-hd.png" for all my sprites, so I just wanted to add that everyone I wanted to know (the images and testing so far were only on the Neretin simulator).

THANK!


EDIT: A problem occurs during retina simulator testing.

0
source share
1 answer

, .

, , . 73x71 , , 128x128, . , 64 ( 32- ). , , , CCSprite setDisplayFrame .

, :

[CCTextureCache sharedTextureCache] addImage:@"player-small.png"]
[CCTextureCache sharedTextureCache] addImage:@"player-orig.png"]

, . , , , - - ,

, / , , .

, 64 . , PVR, PNG , ( ).

TexturePacker PVR.

+2

All Articles