Slow framerate with lots of images

dshoedshoe Member Posts: 62
edited November -1 in Working with GS (Mac)
So I am designing a game similar to the old game Wooly Willy (google it) and that involved spawning quite a few images and after a while the games framerate gets really low (down into 5-8 fps), is there any way around it? I can upload the game later if need be so you guys can see whats going on.

Comments

  • JeffreyShimaneJeffreyShimane Member Posts: 372
    What's being spawned? The little iron shavings you move around with a magnet to give the bald guy hair (assuming it's the same Wooly Willy game I'm thinking of)?

    If so, maybe you could simulate the real game and have a limited amount of iron shavings to use as hair. That would cap the number of images needed. You could even have all the iron shavings on the bottom that the user could drag and place. Then you wouldn't have to spawn/destroy the images and could recycle them. Also, in the actors for the iron shavings, keep the number of rules to a minimum.

    - Jeff
  • outasiteoutasite Member Posts: 417
    How many "hair" actors do you have?
    How do you have the code set up?
    Are they set to non-moveable?

    I would make sure that the hairs are set to non-moveable. Try to minimize as much code a possible that lie inside the hair actors. Constrains and Rules are going to kill you.

    Also, are all of the "hairs" placed at the bottom (You will run into an issue of only picking 1 up. But there is a tutorial somewhere I saw)
    image
    And do you plan to have the "Hairs" like liquid? By that I mean tilt right they move right, tilt left they fall left?
  • dshoedshoe Member Posts: 62
    I have 4 different little images (20x20) and those actors have very little to them, one rule. Dragging them would be a lot harder I think for the user, drawing with the finger is a lot faster and more intuitive. The code is set up that if I touch on the actor Harold (the face) it checks to see if the eraser attribute is = 0 and same for the menu attribute, then it checks to see what the attribute colorHair is and then a random(1,4) and depending on which number it is, it spawns the hair accordingly. I can try getting rid of the random and make it just cycle 1-4. And no they wont be liquid. My main problem is the game lags before they is nearly enough hair down to be practical.

    I also noticed that when I test it on my iPod, Other is at 7.4mb, is that a lot?

    And I still don't know the real meaning of recycling actors.
  • dshoedshoe Member Posts: 62
    Okay then, bump.

    So I tried to make the actor that spawns the images have as little rules as possible so here is what I settled with

    Harold actor (the face)
    -when touched inside, ever 0.05 it cycles through the numbers 1-4 in the HairImage attribute
    -then it checks to see the attribute hairColor
    -if the hairColor = 1 then it spawns BlackHairSpawn

    BlackHairSpawn actor
    -if HairImage = 1 then spawn BlackHair1
    -if HairImage = 2 spawn BlackHair2
    -etc.
    -Destroy

    So I broke the rules that were all originally in the Harold actor into 4 more (for each hair color) to reduce the rules in the Harold actor, this seemed to help a bit but not enough. If anyone would be nice enough to help me out I'll send my proj file to you (granted you wont steal it! >:D)
  • allornothingallornothing Member, PRO Posts: 126
    Just out curiosity, how much is 'lots' of images, on average? Just interested to see some ball park limitations
  • DigiChainDigiChain Member, PRO Posts: 1,288
    I'm also curious about how many images would count as too many? Are there any guidelines elsewhere on this?
  • dshoedshoe Member Posts: 62
    Sorry for the delay, been busy. It seems that the lag begins after about 150 actors are placed. There are no guidelines in place to calculate "too many" yet, but one thing that's for sure is that 150 is not nearly enough.
  • DrGlickertDrGlickert Member Posts: 1,135
    150 actors is a LOT. Especially if they are all "moveable" and they are visible. Is there any way you can cut that down a bit?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    yeah the dr. is right. 150 actors is whats causing your lag

    and there is no guidlines per say. Its all different depenidng on what they do, if there movebale, visible, constrains, ect.

    Ive had games with over 100 actors run perfect, ive had games crash with 50 actors. it all depends.
  • old_kipperold_kipper Member Posts: 1,420
    I would be tempted to try some larger actors that are small areas of texture that could make up the hair and beard etc. This would certainly cut down on the number of actors necessary and might work with the look if you worked on it. A system that spawned particles in a local area might also reduce the actor numbers and might be interesting. Otherwise it is down to dropping the actor numbers I am afraid.

    hope that helps

    kipper
  • dshoedshoe Member Posts: 62
    I have definitely thought about making actors larger. This is really puzzling me, I get so close! Haha, but with any project comes problems. One note, the hair actors are NOT movable, the only rule on them is that if the eraser is turned on and touchX/Y overlap it will destroy the actor. A friend told me to try avoid spawning the actors, the only way I can think of doing this is to place them all outside the screen and somehow, one by one, bring them to the location of the touch. Anyone have any ideas on how to do that? :P I KNOW this is possible!

    PS This was an app idea I had for over a year now so whether I make it in GS or not (coco2d?) this will be done!
  • dshoedshoe Member Posts: 62
    I have made a little progress, first off I tried the app on my iPad and I saw better results, about 270 images before severe lag, so I decided I am going to make this an iPad exclusive until I can get it running good on my iPod. I also decided to start from scratch on the iPad version and now I can put down 700+ images with little slow down, I figure I have something that is causing a memory leak somewhere because there really isn't that much to my game and a performance boost like that is crazy!

    EDIT

    Alright I found the culprit, I have one rule located in the hair images to destroy them (if touch inside and EraserIsOn = 1 then destroy) and that makes all the difference, is there a way to destroy an actor without having any behaviors in the actor that is being destroyed?
Sign In or Register to comment.