Hello everyone.. in my space game i have a obkect that is a explosion animation .. int that object i have 17 diferent animations with about 40 frames each.
So when i spawn it i do a floor(random(17)) to create a variation of the explosion.
But when it does the game freezes for a bit.
Is there a option to preload all animations?
There are three reasons it might freeze,
1) Not enough rendering power on your device in which case you want to optimize the frames and lower the quality of them and adjust frame size based on your game design screen ratio. One mistake most people do when they create a game, is forget to optimize their assets, which saves a lot of memory usage, for images i always use services like tinypng, which compresses the images by 80% or more in some cases, for example from a batch of 20 files at 50mb i get back 2/3mb size batch file. Which is insane, and in the same time very important for game memory usage, your game runs faster, higher fps etc.
2) The 2nd reason it might freeze, is that your load animation event the floor(random(17)) trigger to pick the animation, might run in a loop. Make sure it triggers only once when the bomb explodes, or car explodes or whatever it is. Instead of floor(random(17)) i would use choose(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17) its less computation power for the runtime to calculate, in choose(123...) the runtime picks one item from list 1 time, in floor(random(17)) the runtime has to pick a random number including fractions like 1.111111 ,2.3543677 and then discard the decimal to make it a round fixed number.
3) I mentioned above resizing your images based on your game design screen ration, for example if you have a game that is running on a 864x480 layout, and your animation is like 32x32px then that should be the frame inside the animation, if you have frames that are 256 x256 and you use C2 to resize them down to 32px that might also cause your freeze, because when the animation loads Construct has to resize all frames in that animation in 1-10 ticks to 32px.