Browse Source

joystick fine-tuning

main
Hendrik Langer 4 years ago
parent
commit
09fea432bf
  1. 13
      raspberry/roberto/views/frontend/templates/gamepad.js

13
raspberry/roberto/views/frontend/templates/gamepad.js

@ -116,6 +116,11 @@ var joystick_axes = {
joystick_axes.y1 = -data.vector.y;
joystick_axes.moved = true;
});
joystick.on('end', function(evt, data) {
joystick_axes.x1 = 0;
joystick_axes.y1 = 0;
joystick_axes.moved = true;
});
var joystick2 = nipplejs.create({
zone: document.getElementById('controls_r'),
@ -123,7 +128,7 @@ var joystick_axes = {
//catchDistance: 150,
position: {left: '50%', top: '50%'},
color: 'red',
locky: true
lockY: true
});
joystick2.on('move', function(evt, data) {
@ -131,7 +136,11 @@ var joystick_axes = {
joystick_axes.y2 = -data.vector.y;
joystick_axes.moved = true;
});
joystick2.on('end', function(evt, data) {
joystick_axes.x2 = 0;
joystick_axes.y2 = 0;
joystick_axes.moved = true;
});
setInterval(function(){
if (joystick_axes.moved) {

Loading…
Cancel
Save