Tips and Techniques for an App that Compose of Lots of Images, Tweens, and Sounds

Hi! Good day,

I’m Julian Martin. This is my first time building an Android App and I just want to ask for some techniques and tips that could help me with my project.

Well, I’ve got couple of questions to ask regarding my project and thank you very much in advance.

  1. My project has a lot of images.
  • I use this images to create an animation effect to my app and I display this images using this code “display.newImageRect()” because I want the image on fullscreen. Example, I have an image of a closed cabinet then when tap it, the cabinet will open… I use object.alpha = 0 to hide the image of the close cabinet then alpha = 1 to show the open one. 

Is this kind of method is fine?

  1. Freeing Memory and Texture.
  • I use the code I found to check the current memory and texture that my app consumes. And I noticed that some of my app’s scene consumes almost 500KB of memory.

  • Is there a way to release memory and texture every scene change? Or is there a way to lessen the consumption of memory and texture?

Image:

Code:

    er01= display.newImageRect (“er01.jpg”,xWidth,yHeight,isFullResolution)

    er01.x = _W*0.5; er01.y = _H*0.5

    er01:addEventListener ( “tap”, animate)

    sceneGroup:insert(er01)

    er02 = display.newImageRect (“er02.jpg”,xWidth,yHeight,isFullResolution)

    er02.x = _W*0.5; er02.y = _H*0.5

    er02.alpha = 0

    sceneGroup:insert(er02)

   local function animate ( event )

             er05.tween = transition.to( er05, {time = TRANSITION_TIME - 800, alpha = 0})

             er03.tween = transition.to( er03, {time = TRANSITION_TIME - 800, alpha = 1})

      return true

   end

   

This is the sample of my images, and this is the sample code I’am using to make an animation.

Thank you.

Sincerely,
Julian 

 

Help please… Thanks in advance  :slight_smile:

Hi Julian,

the first thing I would do is to make the second image considerably smaller.
Instead of the entire background, you can use just the part that will actually change, place it in the right spot on the previous image, and only tween it with a fade in, without fading out the older image. This, if done all throughout your project, will save quite a bit of texture memory and file size.
To free the memory between scene changes, make sure that the scenes are actually removed, not just “freezed”. In composer you can use the method described here http://docs.coronalabs.com/api/library/composer/recycleOnSceneChange.html
 

thank you RagdogStudios for the tip… I will try to work on it… kudos!

Help please… Thanks in advance  :slight_smile:

Hi Julian,

the first thing I would do is to make the second image considerably smaller.
Instead of the entire background, you can use just the part that will actually change, place it in the right spot on the previous image, and only tween it with a fade in, without fading out the older image. This, if done all throughout your project, will save quite a bit of texture memory and file size.
To free the memory between scene changes, make sure that the scenes are actually removed, not just “freezed”. In composer you can use the method described here http://docs.coronalabs.com/api/library/composer/recycleOnSceneChange.html
 

thank you RagdogStudios for the tip… I will try to work on it… kudos!