[SOLVED] Graphics order: a flashing square and a blue UI

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
nice
Party member
Posts: 191
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

[SOLVED] Graphics order: a flashing square and a blue UI

Post by nice »

Hello boys and girls!
I'm currently working on a small side project to understand how canvas and saving works in Löve because I got some help on another project where I had some help on making a saving function so now I want to learn it myself.

A fellow Löve user said that I'll need to use the canvas function for my project because in the long run it will be problematic.

So to learn how the canvas function and saving function works I have made a square that switches colors (math.random(0, 255)) and I have also added a light blue "user interface" that will be at the bottom (UI = 800x120, X = 0, Y = 480) but here's the problem:
I know from the previous project that I'll need to set the color white so that I'll keep the UI light blue but I still have a problem that makes everything flash in different colors (both the square and the UI), so my guess is that it has something to do with the order it's in but I can't see what is wrong with it and I have tried different orders but to no avail.

I would appreciate if you could help me out with this small problem..

Code: Select all

function love.load()
	
end

function love.update()
end

function love.draw()
-- Square With Random Color
love.graphics.setColor( math.random(0, 255), math.random(0, 255), math.random(0, 255) )
love.graphics.rectangle("fill", 350, 250, 120, 120)

-- User Interface
love.graphics.draw(ui, 0, 480)
love.graphics.setColor(255, 255, 255)
end
Last edited by nice on Sun Oct 19, 2014 11:35 am, edited 1 time in total.
:awesome: Have a good day! :ultraglee:
User avatar
DaedalusYoung
Party member
Posts: 413
Joined: Sun Jul 14, 2013 8:04 pm

Re: [HELP] Graphics order: a flashing square and a blue UI

Post by DaedalusYoung »

Code: Select all

function love.load()
	
end

function love.update()
end

function love.draw()
-- Square With Random Color
love.graphics.setColor( math.random(0, 255), math.random(0, 255), math.random(0, 255) )
love.graphics.rectangle("fill", 350, 250, 120, 120)

-- User Interface
love.graphics.setColor(255, 255, 255)
love.graphics.draw(ui, 0, 480)
end
Set the colour first, then do the draw call.
User avatar
nice
Party member
Posts: 191
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: [HELP] Graphics order: a flashing square and a blue UI

Post by nice »

DaedalusYoung wrote:Set the colour first, then do the draw call.
Thanks for the Help! It's been a while since I handled colours like this.
:awesome: Have a good day! :ultraglee:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 9 guests