This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by PotHi

Hey guys!

I've created a hud for my game. I'm spawning it on the game init and it should stay alive after the level changing. The problem is that when I loadLevel() the hud "disappear", it is still reachable (I can find it on the using the browser console) but it is not drawn anymore.

I tried to add a zIndex to the hud and sort all entities without success...zIndex didn't worked the way I expected btw. =/

Any ideas?

1 decade ago by Joncom

The order in which you draw things is important. Your HUD might still be there, but is just covered up by your map. Let's see the code you are using to draw your HUD with a little context.

1 decade ago by quidmonkey

Is your HUD an Entity?

1 decade ago by PotHi

@Joncom, yes, I think this is the case, the hud is still there but a lot of things are drawn on top of it.

@quidmonkey, yes it is.

I'm spawning the entity on my game init using the spawnEntity method.
On the game update method I'm updating the pos.x and pos.y from my hud to follow the screen.

The problem happens when I load a new level (using loadLevel method) because impact adds a lot of entities to the screen and my hud "loses its drawing priority".

How can I deal with this case?

1 decade ago by Nico

The problem is that when you call loadLevel() it clears all the background maps and kills all your entities.

I'm pretty sure main will only run init one time unless you leave the game and main gets called again.

Move the spawnEntity code out of main's init and into the loadLevel function and see if that solves it.
Page 1 of 1
« first « previous next › last »