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 »

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 »

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 »

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 »

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 171 times
Aargh, I am wasting my posts! My citizenshiiiip... :o
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 66 guests