function love.load()
local s = love.audio.newSource("TOTE_iT.mp3","static")
s:setVolume(0.9)
s:setPitch(0.9)
love.audio.play(s)
end
function love.update()
if key == "9" then
for i = 1,9 do
wait(1)
text = i +1
end
end
end
function love.quit()
pcall(function() print("Goodbye!")
end)
end
Doesn't show text when I press 9. Help?
Help?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Help?
And why you have assumed it should? What and where sets the value of key? Try either keyboard.isDown() of love.keypressed()/love.keyreleased(), without it there is no way to tell what key was pressed. And no, there is no wait(). Even if there was, you should not use it like that, or your game will freeze. Remember that your love.draw() function should be called about 60 times per second, and it will not be called until love.update() has finished. You should use (dt) from love.update(dt) to increment you accumulator, and then make your changes after passing a threshold.miz656 wrote: Doesn't show text when I press 9. Help?
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Re: Help?
http://love2d.org/wiki/love.keypressed
http://love2d.org/wiki/love.keyboard.isDown
You should really look into the wiki your doubts instead of asking every time. The wiki has the solution to use love commands 90% of the time.
http://love2d.org/wiki/love.keyboard.isDown
You should really look into the wiki your doubts instead of asking every time. The wiki has the solution to use love commands 90% of the time.
Re: Help?
Have you read the documentation for love.keypressed / love.keyreleased ? It should read:miz656 wrote:So you mea
love.keyreleased(9)
?
I'm learning these objects...
Code: Select all
function love.keypressed(key, unicode)
if key=="9" then
...
end
end
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Re: Help?
You have no love.draw(). This is the problem.
Edit: Or variable called text.
example:
Edit: Or variable called text.
example:
Code: Select all
function love.load()
text=""
end
function love.keypressed(key)
if key=="9" then
for i=1, 9 do
text=text..i --If you just used text=i, then it would come out just 9. This adds i to the string, instead.
end
end
end
function love.draw()
love.graphics.print(text, love.graphics.getWidth()/2, love.graphics.getHeight()/2)
end
"your actions cause me to infer your ego is the size of three houses" -finley
Who is online
Users browsing this forum: Ahrefs [Bot] and 12 guests