★★ 31 Optimization Tips ★★
AcceleratedGames
Member Posts: 201
Hello GameSalad Community,
One thing that I know we all care about is performance. Even with the new LUA-Free engine coming soon, we would all still like our games to be fast now. I have made a list of 31 optimization tips to use in your games that I have collected after searching through the forums, coming up with some myself, and exploring GameSalad help websites. I did this so you only needed to go to one thread instead of taking the amount of time it took me to find it all.
Here it is.
1. Uncheck "Preload Art" on as many actors as you can.
2. Uncheck "Movable" for every actor that doesn't have the "Accelerate", "Change Velocity", "Collide", "Move", "Move to", or any of the rotate behaviors.
3. Use the "Interpolate" behavior instead of the "Move", "Move to", and "Change Size" behaviors whenever possible.
4. Use the "Rotate" behavior instead of animations.
5. Turn every attribute under the physics tab in the actor editor to 0 on actors who do not need it.
6. If the actor is not going to be seen, change their "Visible" attribute to false.
7. Instead of using the "Change Image" behavior, use "Change Attribute" and change the self.Image to the desired image's name.
8. Images should be the same size as the actor using them and double the size if you are using Resolution Independence.
9. Change any image that is about 10 pixels more than 8, 16, 32, 64, 128, 256, 512, or 1024 to which ever of these numbers are closest.
10. If an image file is large or is a background, have the actor that uses the image use the suggestion in number 7 instead of having the actor start initially with the image.
11. All images should be 72dpi.
12. Save all images as PNG-24 or PNG-8
13. Save all images as PNG-8 unless they have any transparent or translucent object in them.
14. Don't use the color changer within GameSalad unless necessary.
15. All images should be divisible by 4.
16. Make sure your image creator is set to 8-bits/channel.
17. Don't use the "Display Text" behavior wherever possible.
18. Try not to use so many global attributes and use tables wherever possible.
19. Try not to use timers. See http://forums.gamesalad.com/discussion/44707/timers-are-for-chumps-gs-optimization-tips
20. Limit constrains and if you do need to use it, make sure that they are on the top of your code.
21. Make your own pause instead of using the behavior. See http://gshelper.com/stop-motion-on-custom-pause-gamesalad-tutorial/
22. If an actor is not being used again in the same scene, destroy it.
23. If you have a game that goes on forever like Jetpack Joyride, Temple Run, or Jay & Silent Bob in Too Fat to Fly, make sure you either move or destroy actors that pass you by using these rules:
Landscape gameplay: If attribute game.MainCharacterPositionX > self.Position.X + (game.Screen.Size.Width/2)+(self.Size.Width/2), then destroy or move.
Portrait gameplay: If attribute game.MainCharacterPositionY > self.Position.Y + (game.Screen.Size.Hight/2)+(self.Size.Hight/2), then destroy or move.
24. You do not have to recycle actors that would be destroyed in the first place, like bullets.
25. Use music at your own risk because it will decrease performance.
26. Delete all unused rules, groups, behaviors, actors, attributes, images, and sounds.
27. Don't save more than 3 attributes at once.
28. Don't update all Game Center Achievements/Leaderboards at once unless their is no movement in the scene at that time.
29. Make an initial scene that looks like your splash screen to load attributes and log in to Game Center
30. If you can, unlock actors to constrain to the actor directly. See: http://gshelper.com/gamesalad-performance-tip-1-2/
31. Test your game using Instruments to see the memory, cpu, frame rate, leaks, battery usage, and a lot more.
After using these all in my game, it runs at more than 60 fps on the original iPad constantly.
One thing that I know we all care about is performance. Even with the new LUA-Free engine coming soon, we would all still like our games to be fast now. I have made a list of 31 optimization tips to use in your games that I have collected after searching through the forums, coming up with some myself, and exploring GameSalad help websites. I did this so you only needed to go to one thread instead of taking the amount of time it took me to find it all.
Here it is.
1. Uncheck "Preload Art" on as many actors as you can.
2. Uncheck "Movable" for every actor that doesn't have the "Accelerate", "Change Velocity", "Collide", "Move", "Move to", or any of the rotate behaviors.
3. Use the "Interpolate" behavior instead of the "Move", "Move to", and "Change Size" behaviors whenever possible.
4. Use the "Rotate" behavior instead of animations.
5. Turn every attribute under the physics tab in the actor editor to 0 on actors who do not need it.
6. If the actor is not going to be seen, change their "Visible" attribute to false.
7. Instead of using the "Change Image" behavior, use "Change Attribute" and change the self.Image to the desired image's name.
8. Images should be the same size as the actor using them and double the size if you are using Resolution Independence.
9. Change any image that is about 10 pixels more than 8, 16, 32, 64, 128, 256, 512, or 1024 to which ever of these numbers are closest.
10. If an image file is large or is a background, have the actor that uses the image use the suggestion in number 7 instead of having the actor start initially with the image.
11. All images should be 72dpi.
12. Save all images as PNG-24 or PNG-8
13. Save all images as PNG-8 unless they have any transparent or translucent object in them.
14. Don't use the color changer within GameSalad unless necessary.
15. All images should be divisible by 4.
16. Make sure your image creator is set to 8-bits/channel.
17. Don't use the "Display Text" behavior wherever possible.
18. Try not to use so many global attributes and use tables wherever possible.
19. Try not to use timers. See http://forums.gamesalad.com/discussion/44707/timers-are-for-chumps-gs-optimization-tips
20. Limit constrains and if you do need to use it, make sure that they are on the top of your code.
21. Make your own pause instead of using the behavior. See http://gshelper.com/stop-motion-on-custom-pause-gamesalad-tutorial/
22. If an actor is not being used again in the same scene, destroy it.
23. If you have a game that goes on forever like Jetpack Joyride, Temple Run, or Jay & Silent Bob in Too Fat to Fly, make sure you either move or destroy actors that pass you by using these rules:
Landscape gameplay: If attribute game.MainCharacterPositionX > self.Position.X + (game.Screen.Size.Width/2)+(self.Size.Width/2), then destroy or move.
Portrait gameplay: If attribute game.MainCharacterPositionY > self.Position.Y + (game.Screen.Size.Hight/2)+(self.Size.Hight/2), then destroy or move.
24. You do not have to recycle actors that would be destroyed in the first place, like bullets.
25. Use music at your own risk because it will decrease performance.
26. Delete all unused rules, groups, behaviors, actors, attributes, images, and sounds.
27. Don't save more than 3 attributes at once.
28. Don't update all Game Center Achievements/Leaderboards at once unless their is no movement in the scene at that time.
29. Make an initial scene that looks like your splash screen to load attributes and log in to Game Center
30. If you can, unlock actors to constrain to the actor directly. See: http://gshelper.com/gamesalad-performance-tip-1-2/
31. Test your game using Instruments to see the memory, cpu, frame rate, leaks, battery usage, and a lot more.
After using these all in my game, it runs at more than 60 fps on the original iPad constantly.
Comments
To use Instruments, make an AdHoc version of your game, put it on your device, open the game, then...
https://www.dropbox.com/s/gqrel07c876kai5/Instruments.mov
As long as your image is divisible by 2 or 4 and still remains an even number after dividing it, it should be fine, but keep in mind the memory usage for image sizes, you can wind up wasting a lot of memory on images that are oversized just by a few pixels.
Illustration Portfolio:: |
Our Christmas Wishes for iPad:: |
Astropak for iPhone,
Android
and Kindle Fire
thx
So change self image is faster? I have about 60 actors all changing images on touch.
Illustration Portfolio:: |
Our Christmas Wishes for iPad:: |
Astropak for iPhone,
Android
and Kindle Fire
Illustration Portfolio:: |
Our Christmas Wishes for iPad:: |
Astropak for iPhone,
Android
and Kindle Fire
@Stormtrix - You shouldn't have any problems with that.
@Dougz - Instruments is a program that is used with Xcode.
@JDuaneJ - Using Change Image is not bad, but using change self.image seems to work better, as far as performance is concerned. I haven't noticed a difference personally, but lots of people swear by it.
And any little bit you can do to improve performance is well worth the time to implement the technique for a quicker loading/responding game. It all adds up in the end.
@SlickZero sounds good. I definitely want to make stuff for the long haul so any bit does help. you're right.
I can't see to get the visibility to function correctly with a change attribute. I can get it to work when I physically change the boolean, but not with the change attrib.
Illustration Portfolio:: |
Our Christmas Wishes for iPad:: |
Astropak for iPhone,
Android
and Kindle Fire
Illustration Portfolio:: |
Our Christmas Wishes for iPad:: |
Astropak for iPhone,
Android
and Kindle Fire
I think I will have to pinch it for my blog so I can always find it!
: )
what does the above mean?#
does this mean, i shouldn't recycle
Yeah, I'm a little confused by that one too, since time began people have always advised you to recycle so you are not spawning hundreds of actors . . . . so it's weird to see 24 ?
Cheers for the explanation, I wasn't aware of the destroy bug.