Hello,
I’m trying to hide the joystick, but instead I get an error.
I am using plugin “Typler’s Joystick”
I tried that:
[lua]
Joystick.setCoords(x: 10,y: 1000)
[/lua]
Hello,
I’m trying to hide the joystick, but instead I get an error.
I am using plugin “Typler’s Joystick”
I tried that:
[lua]
Joystick.setCoords(x: 10,y: 1000)
[/lua]
I would expect there to be a better way to hide your joystick. Still, the reason why you are getting that error is because of what you are trying to pass to the function. All you need is: Joystick.setCoords( 10, 1000 )
Adding those “x: 10” isn’t how you pass parameters to functions in Lua, you just insert the value.
And also, try to come up with more descriptive titles for your posts.
I would expect there to be a better way to hide your joystick. Still, the reason why you are getting that error is because of what you are trying to pass to the function. All you need is: Joystick.setCoords( 10, 1000 )
Adding those “x: 10” isn’t how you pass parameters to functions in Lua, you just insert the value.
And also, try to come up with more descriptive titles for your posts.
im trying to use this joystick but i dont have an example. I have put this code in build.setting:
plugins =
{
[“plugin.joystick”]=
{
publisherId = “com.typler”
},
},
And i have put the require(“plugin.joystick”) in my game.lua scene.
Now i dont know how to put the joystick on the screen
If you put code into build.settings file correctly then add in your game.lua scene then add folowing lines:
[lua]
local joystick = require “plugin.joystick” – adding joystick plugin to scene
local Joystick = joystickPlugin.newJoystick(props) --creating joystick
Joystick.background:setFillColor(0.5) – with these two you can customize your joystick
Joystick.movedStick:setFillColor(0.7)
[/lua]
then you need to create a enter frame function:
[lua]
function enterFrame(event)
if Joystick.isActivated() then
local vector = Joystick.getVector()
if vector.x < -0.5 then
print(“left”)
elseif vector.x > 0.5 then
print(“right”)
end
if vector.y < -0.5 the
print(“up”)
elseif vector.y > 0.5 then
print(“down”)
end
end
end
Runtime:addEventListener(“enterFrame”, enterFrame)
[/lua]
Also thanks to Rob for explaining it to me.