Simple question
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Simple question
I want to know, when a button is pressed, how to keep the function active after the button has been used. with what function do I do this?
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Simple question
Hi and welcome to the forums;
Your simple question is truly simple, yet oh so vague; let me ask you a few follow-up questions:
- Do you mean mouse button, or a graphical button object you might have coded or want to code?
- What function do you exactly want to keep alive? And how do you define "keep alive"?
- What do you mean by "after the button has been used? As in the mouse-button released? Or a graphical one clicked on?
- Do you perhaps want a function to be called/executed/ran every frame after one of the aforementioned things, or would you like to do something else?
You know, help us help you, so we can give you a correct answer.
Your simple question is truly simple, yet oh so vague; let me ask you a few follow-up questions:
- Do you mean mouse button, or a graphical button object you might have coded or want to code?
- What function do you exactly want to keep alive? And how do you define "keep alive"?
- What do you mean by "after the button has been used? As in the mouse-button released? Or a graphical one clicked on?
- Do you perhaps want a function to be called/executed/ran every frame after one of the aforementioned things, or would you like to do something else?
You know, help us help you, so we can give you a correct answer.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Simple question
You tie the input command to a boolean variable.
When the spacebar is pressed, switchOn becomes true and stays true even if released.
Code: Select all
function love.load()
switchOn = false
end
function love.update(dt)
if love.keyboard.isDown('space') then
switchOn = true
end
if switchOn then
doSomething()
end
end
Re: Simple question
Thanks Ostego160 ! it solves my problem.
Who is online
Users browsing this forum: No registered users and 7 guests