I have three buttons to control movement of a character. Each one has a button id defining which way the button moves the player. I did this so I could have one function that gets called when any of the buttons are pressed. Based on the button id, the function applies a linear velocity to the player. It looks like this:
local function onCtrlBtnRelease(event) print(event.id, "button pressed")--for debugging if event.id == "left" then player:setLinearVelocity(-100, 0) elseif event.id == "right" then player:setLinearVelocity(100,0) elseif event.id == "up" then player:setLinearVelocity(vx, -200) end return true end
However, whenever the print statement is called, it says
userdata: 00000001 button pressed
I have tried using self instead of event and I get the same result. Do I need to pass the button itself as an argument? I could really use some help. Thanks in advance!