Optimising for iPhone 3GS

MetzoPainoMetzoPaino Member Posts: 195
edited May 2012 in Working with GS (Mac)
Hey everyone,

My app is almost finished, but I'm noticing that when I test the game through the GS Viewer it will lag, both when connected to GameSalad (fps jumps all one the place, usually 60fps to 30fps, but sometimes down to 19fps) and when played from Recent Games. My project size is 4.0MB and Memory Usage starts at 70MB but creeps up to 80MB. Images are about 30MB.

In the game you control an avatar left to right avoiding falling objects which when they leave the screen are destroyed until you eventually die. I guess maybe one of the things is that everything happens in one scene, but when something isn't needed (the menus) they are destroyed and then respawned when needed.

So yeah, any advice for getting this to run better? I realise that the 3GS is a little weak, but it seems like something aint right. There are a couple of constrain attributes, but I did try and use change attribute behaviours when I could.

Best Answer

  • v00d0v00d0 Posts: 143
    Accepted Answer
    i'm creating something similar to your project, and on 3gs i reach 30MB, no more. the biggest problem were the animations, now i've max 10 frames for actor and with this i solved the fps problem. then i found, for example, better to divide the background to smaller images; i had a background with buildings; i created three groups of buildings and divided them into 3 images and i saved around 10 MB. then i switched all change image attribute (for scores and things) with change attribute, this save a lot of memory. then try to pass your IMAGES into PNG-Inspector, u can download it for free on the deep blue apps web site.

Answers

  • MetzoPainoMetzoPaino Member Posts: 195
    I can't really cut down the animations. (Though things rarely animate as the main character only changes their image when they take damage and animates only when they've died or coming to life with 40 frames) The objects to avoid are single images that use the rotate behaviour to look animated.

    My background is just one block image at at 640 x 960, though only 0.02MB in size, but I did want it to animate slightly once or twice a minute so I'll try breaking it up.

    PNG-Inspector seems to be a-ok with all my images.

    There can be up to 20 objects to avoid on screen at once if that makes a difference. But they don't animate and just head downwards with the move behaviour.
  • Fabri DamazioFabri Damazio Member Posts: 97
    Did you tested on a Ad Hoc version?
  • MetzoPainoMetzoPaino Member Posts: 195
    Did you tested on a Ad Hoc version?
    No not yet, is GS Viewer not accurate?
  • MetzoPainoMetzoPaino Member Posts: 195
    i switched all change image attribute (for scores and things) with change attribute, this save a lot of memory.
    Change Attribute is more optimised than Change Image?
  • MetzoPainoMetzoPaino Member Posts: 195
    Another thing, I'm spawning my objects to be avoided higher than the player can see (500-600) in portrait mode. This is to add some randomness to their patterns, and also to give time for any that will collide to do so and be destroyed, because if they clump up while the player can see it it looks horrible. I suppose that is increasing the image amount.

    Maybe there is a way that they don't have an image until 450 and that will be better?
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    @MetzoPaino -
    i switched all change image attribute (for scores and things) with change attribute, this save a lot of memory.
    Change Attribute is more optimised than Change Image?
    Yeah, it saves memory - pretty easy to use, too!
  • v00d0v00d0 Member Posts: 143
    i switched all change image attribute (for scores and things) with change attribute, this save a lot of memory.
    Change Attribute is more optimised than Change Image?
    it's what i said

  • MetzoPainoMetzoPaino Member Posts: 195
    i switched all change image attribute (for scores and things) with change attribute, this save a lot of memory.
    Change Attribute is more optimised than Change Image?
    it's what i said

    That seems so crazy. GameSalad is a strange beast.

    I'll get on that now and see what happens, but I'm open to any other suggestions on how to trim my app's fat.
  • MetzoPainoMetzoPaino Member Posts: 195
    Ok so just did the change attribute change. It has helped, but not a tonne. Still some jumpy frame rates.
    I'll try an ad hoc version and breaking up the retina sized background tomorrow to see if that helps.
    Looks like I still need some work arounds though.
  • UtopianGamesUtopianGames Member Posts: 5,692
    This has been a problem for ever or as long as i can remember...fingers crossed they dump soon so we can use more images.

    Darren.

  • MetzoPainoMetzoPaino Member Posts: 195
    edited May 2012
    By the way, just so you have some context about the amount of images, a typical screenshot of gameplay:

    Photobucket
  • MetzoPainoMetzoPaino Member Posts: 195
    edited May 2012
    Ok, getting rid of the larger images and also changing change image to change attribute has helped, but it still takes frame rate hits.

    If I make an image at 300 x 300, but then use it on an actor that is 30 x 30 and never make that actor larger am I throwing away RAM? Or is GameSalad smart enough to not do that?

    Below is an image of my memory usage. Anything out of the ordinary? What is other?

    Photobucket
Sign In or Register to comment.