1 decade ago by BFresh
I'm starting this thread to help collect ideas and methods to optimize any game for use on mobile devices. As I get farther into creating a game, I've realized the significant processing ability differences. My sloppily coded game ran perfect on a desktop but barely ran on a mobile until I did a few things. Note that I am a self-taught programmer and a lot of this is trial and error and I don't have the best understanding of how long different algorithms or functions may take. I'll start listing some things I've done to my first game so far:
-No sounds on mobile
-Spawn entities such as enemies just outside of screen so they don't always exist and take up resources before the player can be affected by them
-For entities such as platform movers or things that need to be updated during the entire level to determine their position,etc, I only perform their draw() function when they are just within view of the player. Update() is still calculating everything they need, they just aren't drawn unless the player can see them. I think this helps?
-If the entity is a particle, gib, lighting effect, or something else that doesn't impact gameplay and is eye candy, significantly limit the quantity spawned on a mobile
-Extend entities that share the same properties and functions as much as possible to simply cut down code.
-Get player or any other entity you may need to access from many other entities just once in the main game loop and reference to it as ig.game.player where you need it to cut down on the amount of times .getEntitiesByType needs to be used
-Optimize images for loading time - .png's are generally used since transparency is typically needed. .Png's can be converted from 24bit down to indexed colors and usually still look good as long as transparent gradients aren't used. - those start to look bad when color depth is lost. This helped a few of my .png's get from 88k to 22k and look the same to me. I used .jpg images when I had no transparency in that particular image.
That's what I've done so far, out of ideas!
-No sounds on mobile
-Spawn entities such as enemies just outside of screen so they don't always exist and take up resources before the player can be affected by them
-For entities such as platform movers or things that need to be updated during the entire level to determine their position,etc, I only perform their draw() function when they are just within view of the player. Update() is still calculating everything they need, they just aren't drawn unless the player can see them. I think this helps?
-If the entity is a particle, gib, lighting effect, or something else that doesn't impact gameplay and is eye candy, significantly limit the quantity spawned on a mobile
-Extend entities that share the same properties and functions as much as possible to simply cut down code.
-Get player or any other entity you may need to access from many other entities just once in the main game loop and reference to it as ig.game.player where you need it to cut down on the amount of times .getEntitiesByType needs to be used
-Optimize images for loading time - .png's are generally used since transparency is typically needed. .Png's can be converted from 24bit down to indexed colors and usually still look good as long as transparent gradients aren't used. - those start to look bad when color depth is lost. This helped a few of my .png's get from 88k to 22k and look the same to me. I used .jpg images when I had no transparency in that particular image.
That's what I've done so far, out of ideas!