Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:42:38+00:00 2026-05-27T00:42:38+00:00

One of the powerups in my game is a decrease in size of the

  • 0

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.

So, I am using this code for making it small:

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

and this code for resetting back to normal:

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

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.

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.

Here’s some visual examples:

Original:

Original


Retextured Image with contentSize modification:

Retextured Image with contentSize modification


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):

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 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).

THANK YOU!


EDIT: Issue occurs during testing on retina simulator as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:42:38+00:00Added an answer on May 27, 2026 at 12:42 am

    Since your main concern is about memory, I recommend to simply use a texture atlas.

    I copied your original image into an image editing program to see what its dimensions are. The image is 73×71 pixels in size, that means it’s stored in memory as a texture with dimensions 128×128 since textures will have power of two dimensions. This will have the texture use up 64 KB of memory (assuming 32-bit color depth). With a texture atlas you’ll be able to pack your textures more tightly, and you can change the frame that is displayed more easily with the CCSprite setDisplayFrame method.

    Furthermore, you are using the texture cache:

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

    Unless you explicitly free the memory of that texture, both textures will remain in memory anyway. If you do free the memory of the texture you’re not currently using, and exchange these texture often, your game will spend a great deal of time releasing memory and reloading the image from the device’s flash memory – even if the image is relatively small.

    And if there’s more than one sprite using either texture it wouldn’t make any sense to try and unload/reload the textures because there will be occurrences where two or more sprites will use either texture.

    Finally, we’re talking about 64 KB of memory at most. If you’re concerned about memory usage AND performance, the thing you should do is to load PVR textures instead, which are a fraction of the size of a PNG file both in memory and on disk (but losing some color vibrancy).

    Have a look at TexturePacker for creating texture atlases and PVR images.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

One of my project is to download several large size files using ASIHTTPRequest in
one of my users are reporting this error for my game. i am using
One of those classic programming interview questions... You are given two marbles, and told
One of my biggest typographical frustrations about HTML is the way that it mangles
One of the articles I really enjoyed reading recently was Quality Control by Last.FM
One of my co-workers checked in a some files in SVN and one of
One of the fun parts of multi-cultural programming is number formats. Americans use 10,000.50
One of the joys of working for a government healthcare agency is having to
One may not always know the Type of an object at compile-time, but may
One thing I've always wanted to do is develop my very own operating system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.