TheOnlyWRT
Member
Hey guys!!
So I am working on an iOS app and am trying to program in a virtual joystick. I watched one tutorial video to make a joystick object, but it seems that the code is not quite working. When i drag around the inner circle, the value does not change (i drew it to make sure). Here is the code of the VStick Object.
CREATE:
STEP:
ALARM 0:
SCRIPT "checkVStickDirection()"
might i add that i also need this to check if it is both down AND left, or down AND right. So i hope with that code i can figure out how to get this working, thanks a ton!
So I am working on an iOS app and am trying to program in a virtual joystick. I watched one tutorial video to make a joystick object, but it seems that the code is not quite working. When i drag around the inner circle, the value does not change (i drew it to make sure). Here is the code of the VStick Object.
CREATE:
Code:
//where the tap begins
tapX = device_mouse_x_to_gui(0);
tapY = device_mouse_y_to_gui(0);
//the other circle
circleX = 0;
circleY = 0;
//the mac distance the inner circle can be drawn
maxDistance = 150;
//the alarm to read input
alarm[0] = 2;
Code:
circleX = device_mouse_x_to_gui(0);
circleY = device_mouse_y_to_gui(0);
x = tapX;
y = tapY;
if(!device_mouse_check_button(0, mb_left)){
checkVStickDirection();
objectPlayer.vstickDirection = -1;
instance_destroy();
}
Code:
checkVStickDirection();
alarm[0] = 2;
Code:
/// @description checkVStickDirection()
/// @function checkVStickDirection
//up direction
if((point_direction(xstart, ystart, x, y) > 45) && (point_direction(xstart, ystart, x, y) < 135)){
objectPlayer.vstickDirection = 0;
}
//down direction
if((point_direction(xstart, ystart, x, y) > 135) && (point_direction(xstart, ystart, x, y) < 225)){
objectPlayer.vstickDirection = 1;
}
//left direction
if((point_direction(xstart, ystart, x, y) > 225) && (point_direction(xstart, ystart, x, y) < 315)){
objectPlayer.vstickDirection = 2;
}
//right direction
if((point_direction(xstart, ystart, x, y) > 315) && (point_direction(xstart, ystart, x, y) < 45)){
objectPlayer.vstickDirection = 3;
}