Page 1 of 1

Player sprite on top of other sprites

Posted: Mon May 06, 2013 3:47 am
by thecodejunkie
I am new to this language and I can't figure out how to make my player sprite always on top of my other sprites. Currently it is under my grass sprite, and I don't know why or how to fix it. Can anyone help?

Re: Player sprite on top of other sprites

Posted: Mon May 06, 2013 5:29 am
by micha
That depends on the drawing order. You have something like this:

Code: Select all

drawPlayer
drawGrassTile
but you need this:

Code: Select all

drawGrassTile
drawPlayer

Re: Player sprite on top of other sprites

Posted: Mon May 06, 2013 1:13 pm
by thecodejunkie
Thank you!

Re: Player sprite on top of other sprites

Posted: Tue May 07, 2013 9:15 am
by rhezalouis
Hi thecodejunkie,

P.S. Please attach your *.love file to help other people to help you.

if you have several objects to draw and some might be in front of the other, you might want to manage the rendering order by some means.
  1. Order the drawing function manually as suggested by micha.
  2. Or create an object manager that stores them in order as you create them.
  3. Or add a variable in the object, then let the object manager draw each object in the order of that variable.
  4. Or create table called backgroundLayer, playerLayer, foregroundLayer, then put everything you want to draw at that level in the respective table then draw them background first, then the player, then the foreground objects.
An example of the second option could be found in the attachment below. I hope it's not too complex than it should :roll:.