Player sprite on top of other sprites

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
thecodejunkie
Prole
Posts: 18
Joined: Sun May 05, 2013 11:34 pm

Player sprite on top of other sprites

Post by thecodejunkie » Mon May 06, 2013 3:47 am

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?

User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Player sprite on top of other sprites

Post by micha » Mon May 06, 2013 5:29 am

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

thecodejunkie
Prole
Posts: 18
Joined: Sun May 05, 2013 11:34 pm

Re: Player sprite on top of other sprites

Post by thecodejunkie » Mon May 06, 2013 1:13 pm

Thank you!

User avatar
rhezalouis
Party member
Posts: 100
Joined: Mon Dec 07, 2009 10:27 am
Location: Indonesia
Contact:

Re: Player sprite on top of other sprites

Post by rhezalouis » Tue May 07, 2013 9:15 am

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:.
Attachments
thecodejunkie-renderingOrder2.love
LÖVE 0.8.0
(3.23 KiB) Downloaded 56 times
Aargh, I am wasting my posts! My citizenshiiiip... :o

Post Reply

Who is online

Users browsing this forum: Google [Bot], Whitecurse and 7 guests