• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android Virtual joystick problem when using camera_get_view_x

  • Thread starter Sorry_For_Dumb_Questions
  • Start date
S

Sorry_For_Dumb_Questions

Guest
Hello everyone.
I was trying to make virtual joystick for android.
So i watched a tutorial and tried. It worked.

But the tutorial didn't use the cameras and views.
So i tried it myself.

The problem is : When objplayer moving out of screen and screen follows him (= when screen moves) the virtual joystick moves a little bit (and i have a bigger problem, if i moved v.joystick fast, while screen move it stucks)

Probably you will see the problem of my code in 1 minute but i tried to figure out for 8 hours. Still couldn't :(


sorry for long introduction.



THE CODES;

objjoystick

--- create-event

maxuzaklik= 200; // maxuzaklik = maxdistance in my language
aktif = false;

x = camera_get_view_x(view_camera[0]) + 320;
y = camera_get_view_y(view_camera[0]) + 730;

xorjin = camera_get_view_x(view_camera[0]) + 320; // when leave the button, x will -> xorjin
yorjin = camera_get_view_y(view_camera[0]) + 730;// when leave the button, y will -> yorjin



--- draw event

draw_self();
draw_set_color(c_white);
draw_circle(xorjin,yorjin,maxuzaklik,true);

--- STEP EVENT (%90 the problem is here)

var temp_angle;
temp_angle = point_direction(xorjin,yorjin,mouse_x,mouse_y);

if device_mouse_check_button(0, mb_left) && position_meeting(mouse_x,mouse_y,id)
{


if point_distance(xorjin,yorjin,mouse_x,mouse_y) <= maxuzaklik
{
x = mouse_x;
y = mouse_y;
aktif = true;
}

if aktif = true && point_distance(xorjin,yorjin,mouse_x,mouse_y) > maxuzaklik
{
x = xorjin + lengthdir_x(maxuzaklik,temp_angle);
y = yorjin + lengthdir_y(maxuzaklik,temp_angle);
}



}


if !device_mouse_check_button(0, mb_left)
{
aktif = false;
}


if aktif = false
{
x = xorjin; // back to the screen view position 320,730
y = yorjin;
}

xorjin = camera_get_view_x(view_camera[0]) + 320;
yorjin = camera_get_view_y(view_camera[0]) + 730;




if aktif = true // to move objplayer
{
objplayer.x += (x - xorjin) / maxuzaklik * objplayer.speed;
objplayer.y += (y - yorjin) / maxuzaklik * objplayer.speed;
}
 
Last edited by a moderator:
Top