Clicking to draw?

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
Xoria
Citizen
Posts: 61
Joined: Sun Jan 31, 2010 1:24 am

Clicking to draw?

Post by Xoria »

No matter where I put this, when I place this, I click my thing doesn't appear. Why?


Code: Select all

-- In love.draw \/
function loadplanetEarth()
------planetEARTH !
---moon(s)*
love.graphics.draw(planetEarth.moon.image,planetEarth.moon.x+camera.x,planetEarth.y+camera.y, math.rad(planetEarth.angle),planetEarth.moon.width,planetEarth.moon.height,16,16)

--Earth*
love.graphics.draw(planetEarth.image,planetEarth.x+camera.x,planetEarth.y+camera.y, math.rad(planetEarth.angle),planetEarth.width,planetEarth.height,16,16)
end

--In love.update \/


if love.mouse.isDown("l") then
loadplanetEarth()
end

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Clicking to draw?

Post by Robin »

In love.update(), do:

Code: Select all

if love.mouse.isDown("l") then
     showEarth = true
end
And in love.draw():

Code: Select all

love.graphics.draw(planetEarth.moon.image,planetEarth.moon.x+camera.x,planetEarth.y+camera.y, math.rad(planetEarth.angle),planetEarth.moon.width,planetEarth.moon.height,16,16)
love.graphics.draw(planetEarth.image,planetEarth.x+camera.x,planetEarth.y+camera.y, math.rad(planetEarth.angle),planetEarth.width,planetEarth.height,16,16)
Help us help you: attach a .love.
Xoria
Citizen
Posts: 61
Joined: Sun Jan 31, 2010 1:24 am

Re: Clicking to draw?

Post by Xoria »

How is the 2nd code you gave affiliated to showEarth? Are you saying that I should do:

Code: Select all

If showEarth == true then
love.graphics.draw(planetEarth.moon.image,planetEarth.moon.x+camera.x,planetEarth.y+camera.y, math.rad(planetEarth.angle),planetEarth.moon.width,planetEarth.moon.height,16,16)
love.graphics.draw(planetEarth.image,planetEarth.x+camera.x,planetEarth.y+camera.y, math.rad(planetEarth.angle),planetEarth.width,planetEarth.height,16,16)
end
Why do I get an error report? It's like "'=' expected near showEarth".
User avatar
kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

Re: Clicking to draw?

Post by kalle2990 »

I think if is case sensitive, you can't use If ;)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Clicking to draw?

Post by Robin »

Both right -- I forgot to surround it by if.
Help us help you: attach a .love.
Xoria
Citizen
Posts: 61
Joined: Sun Jan 31, 2010 1:24 am

Re: Clicking to draw?

Post by Xoria »

Awesome. Worked. One more thing. How do you "destroy" the table if showEarth is false? I need to do this, because Earth is affiliated with lots of vars that count up while it's alive.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Clicking to draw?

Post by bartbes »

planetEarth = nil?
Anyway, I wanted to say that == true is useless, if a then is the same as if a == true then (for booleans, anyway).
Post Reply

Who is online

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