There is a working space:

#joystick { width: 726px; height: 346px; } 

there is a picture 320x180
it needs to be dragged in the joystick space
Positioning is a center with coordinates x and y centers is ( 0; 0 )
when you move it to the upper left corner, then the coordinates should be: -5; -5
extreme top corner is 0.5; -0.5
sketched the following code: jsfiddle.net/AsviS/gpkn3djf
don't understand how to make a joystick equal to 1?
so that the coordinates in the center were 0; 0 and the extreme upper angle is 0.5; -0.5

  • one
    It is not entirely clear what is meant. but why not just do it like this? var rel_left = (ui.position.left - parseInt($(this).data("startLeft")))/50; var rel_top = (ui.position.top - parseInt($(this).data("startTop")))/50; - Batanichek
  • yes yes, divided by 50, also came to this :) jsfiddle.net/gpkn3djf/3 - MasterAlex

0