Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS and Cocos2d - Changing CCSprite's image AND new dimensions = FAIL
    primarykey
    data
    text
    <p>One of the powerups in my game is a decrease in size of the main sprite. So for memory sake, instead of looping a sprite.scale through each frame, I resaved the sprite at a percentage size lower than the original sprite, and just wish to replace it. Then once "death" occurs or timer runs out, the original sprite returns.</p> <p>So, I am using this code for making it small:</p> <p><code>[player setTexture:[[CCTextureCache sharedTextureCache] addImage:@"player-small.png"]];</code></p> <p>and this code for resetting back to normal:</p> <p><code>[player setTexture:[[CCTextureCache sharedTextureCache] addImage:@"player-orig.png"]];</code></p> <p>however, the orignal image (both in the init and when reset) looks normal. But when I change it to the new sprite (which has dimensions exactly 75% of the original), it changes it, but shows only a quadrant of the new sprite, but with the original dimensions.</p> <p>I tried modifying the sprite.contentsize before retexturing the sprite, but all that did was change the size, but not affect the issue with the image messing up.</p> <p>Here's some visual examples:</p> <p>Original:</p> <p><img src="https://i.stack.imgur.com/l7APD.png" alt="Original"></p> <hr> <p>Retextured Image with contentSize modification:</p> <p><img src="https://i.stack.imgur.com/44RZ5.png" alt="Retextured Image with contentSize modification"></p> <hr> <p>Retextured 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):</p> <p><img src="https://i.stack.imgur.com/zYQUD.png" alt="Retexted image to the Original image with the contentSize not reset properly (oops, but this isn&#39;t a problem at all - i just forgot to readd the size code):"></p> <p>PS -- I do have "-hd.png" versions of all of my sprites, so i just wanted add that incase anyone wanted to know (the images and testing so far has only been on "nonretina" simulator).</p> <p>THANK YOU!</p> <hr> <p>EDIT: Issue occurs during testing on retina simulator as well.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload