I’m starting coding with Felgo and got stuck on joystick
I was trying to control an image with joystick but it only works if I keep moving the joystick. (onControllerXPositionChanged)
I want the image to keep moving for example to the left when the XPosition is -1 and not only if the XPosition has changed form 0 to -1
Here is the code:
import Felgo 3.0
import QtQuick 2.0
GameWindow {
property alias joystickBackgroundImageSource: joystick.backgroundImageSource
// this rectangle fills the whole screen with grey
Rectangle {
id: bg
anchors.fill: parent
color: "light gray"
}
Scene {
id: scene
Image{
id: goku
source: "https://i.pinimg.com/originals/a1/66/71/a1667139446a400786829073db83a20b.png"
height: 200
width: 100
}
JoystickControllerHUD {
id: joystick
anchors.right: parent.left
anchors.top: parent
width:100;height:100
onControllerXPositionChanged: {if(controllerXPosition>0){
goku.x=goku.x+5
}
if(controllerXPosition<0){
goku.x=goku.x-5
}
}
onControllerYPositionChanged: {
if(controllerYPosition>0){
goku.y=goku.y-5
}
if(controllerYPosition<0){
goku.y=goku.y+5
}
}
}
}
}
Thank you