Performance on an image or rect etc

Hello I am trying to further optimize my battle code. What I have is when I press a button (sword) I spawn a physics shape that takes on like a “sword” box that is invisible to the user. I also switch out the player animation from walking to the sword animation. What I am asking is the sword box is separate and use to hold a giant physics shape and I wanted to figure out a way to optimize it better. 

Right now I do:

game.actionPlayer\_1 = display.newSprite(game.mSheet, sequenceData) game.actionPlayer\_1.isVisible = false ...do some physics creation work and set the .type to the sword

Just to get the physics shape for collision as I don’t need an actual image or picture,  before it was holding a giant image and I ended up changing it to some blank 32x32 image (only way I could figure out to get the physics to work), but I was thinking of changing it to like a 2x2 blank image…all this sounds silly and was thinking of just setting it to a newImageRect that is invisible (like a simple invisible box would be more efficient than a image taking up memory space even if blank?) as I only need some physics shape to spawn, and using a blank 32x32 image doesn’t seem very efficient or any image.

Thanks for your time.

Hi Azmar,

Smaller images take up less texture memory (sometimes significantly so). So, a 2x2 image is better to use than a 32x32 image, although if you’re only talking about one image, then the difference would be negligible.

If you want to read about the “math” involved on this, please see here, under “Conserving Texture Memory”:

http://docs.coronalabs.com/guide/basics/optimization/index.html#texturemem

Take care,

Brent

Hi Azmar,

Smaller images take up less texture memory (sometimes significantly so). So, a 2x2 image is better to use than a 32x32 image, although if you’re only talking about one image, then the difference would be negligible.

If you want to read about the “math” involved on this, please see here, under “Conserving Texture Memory”:

http://docs.coronalabs.com/guide/basics/optimization/index.html#texturemem

Take care,

Brent