Game crashes when actor spawn
Kungvald
Member Posts: 31
in Help Wanted
Hi!
I have a game where i want something like flappy bird to happen. After a few seconds i would like pipes to spawn and move towards my player. At the same time i have enemies that spawns and move towards my player. The problem is that the game work perfect on my ipad without the pipes. When i activate the pipes and install the game on my ipad, the game starts but as soon as the pipes spawns, the game crashes.
does anyone know why this happens to me?
Comments
Do you have LOTS of pipes all loaded at once? It sounds like you're running out of memory. Are you recycling the pipes, rather than just spawning new ones? And how big are your textures?
hi. I only spawn new ones, how do you mean with recycling? if you mean to destroy them when they leave the sceene, then yeas I do that. but the thing is that i use 100 x 100 png file with size 68.8 kb. this is not exactly the texture of pipes, i only wrote that so you understood what i was talking about. This is image of a block. i changed the vertical wrap to tile and then changed the size of the actor.
The other thing is that the actor do not even get the chance to destroy when it leaves the scene, because the game crashes before the actor even arrives to the scene.
i hope you understand what im talking about.
Rather than destroying and spawning new ones, you should reset their positions when they leave the screen, not destroy them. That way you can use much fewer actors by reusing them. Not sure if that's your issue, though...
Also, all textures should be power of 2, so 32, 64, 128, 256 and so on. A 100100 texture will take up as much memory as a 128128 texture and a 130130 texture will take up the same as a 256256! So best stick to correct sizes. Again, won't be causing your issue but it's good to know.
How many pipes or other actors do you have spawned (on or off screen) at any one time?
thanks for that about the texture size.
i have one spawner that spawns enemie planes, that moves towards the player and then this player with the "pipes". im going to try change to reset their positions instead of destroying them, and see if that helps. but it should be something else, because a small thing like that should not cause this problem, but hey, im new to this
Yeah that shouldn't cause it unless you have heaps of actors or really large textures.
I spawned all my bullets in Max Vector when I was starting out, found out that the game would crash, as they weren't being destroyed properly and built up in memory. My fix was to spawn less, dumb the game down. Wish I'd thought of recycling back then! Lol. Then again, that was 2010 and devices were much less powerful!