Is there a way to assign or change the depth of a class placed on the stage?


I’m workng a top down shootemup.

So I have the players ship placed on the stage. I’ve put it as late in the draw function past my other objects.

I have code which adds items to tables for enemies and bullets and they automatically appear on top.

Now this isn’t an issue until I use a manoeuvre in game where the ship does a loop the loop over the enemies (like the arcade game 1941). But as the enemies are added to the table they have a depth that automatically higher than the player’s ship.

Is there a line of code I can apply to change the depth of the ship?


I have no idea what you are asking for but…

its called z, the third cordinate of X Y Z, with something like

Position=vec3(X, Y, Z)

With the X, Y, Z being the cordinates you want it to be,
You can later get the number with Position.x, Position.y or Position.z

Im sorry if it wasnt what you were asking for but just stay tuned until someone who knows what they are doing actually comes by.

Hey @Kire thanks for your answer. I’ll look into that.

I have solved my problem already, had an ‘end’ code in the wrong place :wink:


@Majormorgan heh

@Majormorgan I know you already fixed it, but if you want to hard-code the depth of an object on the screen, you can use the zLevel function.

Hey @SkyTheCoder many thanks, that will come in handy as I think with it I can switch the levels. Thanks!