I am trying to make a button that when pressed & Held, will make my character move on the screen. What i cant figure out it the correct way to code for this, all i know is that there is “began” and “release”. are there any other phases than this?
what i have right now is im creating a local variable
local accelerateActive = false
then i have my move forward code running on a EnterFrame Listener. And i say that if accelerateActive = true then … move my guy
Now here is what id like to figure out, i want it so while you hold the button down accelerateActive = true. I can get it to turn true when i tap the button once… but i need it to turn active while held down, and once let off then to turn off
any ideas?
here is what i was trying but it does not work…
local function accelerate(event)
if accelerateActive == true then
local s = tireObject.angularVelocity
tireObject.angularVelocity = s + 100
end
end
--
local function moveForward(event)
if event.phase == "began" and menuisActive == false and gameActive == true then
accelerateActive = true
elseif event.phase == "ended" and menuisActive == false and gameActive == true then
accelerateActive = false
end
end
[import]uid: 19620 topic_id: 7545 reply_id: 307545[/import]