width: 200
height: 200
- Rectangle {
- id:knob
- x:parent.width/2-width/2
- y:parent.width/2-height/2
- width:20;
- height:20;
Image {
- anchors.centerIn:parent
- id: knobimage
+ id:knob
+ x:parent.width/2-width/2
+ y:parent.width/2-height/2
source: "joyknob.png"
}
- }
TouchArea {
id: joyarea
onTouchMove: {
// console.log("TouchArea:ontouchMove " + joyarea.changedTouches.length);
var touch = joyarea.changedTouches[0];
- // console.log("touchMove",touch.id," at ",touch.y,touch.x);
- knob.x=touch.x;
- knob.y=touch.y;
+ // console.log("touchMove",touch.id," at ",touch.y,touch.x);
+ if((touch.x<width) && (touch.x>0)) knob.x=touch.x;
+ if((touch.y<height) && (touch.y>0))knob.y=touch.y;
}
onTouchEnd: {