Lite
Member
Clicking on an enemy object picks them up and the enemy follows the mouse x/y until you release the mouse button at which time the enemy object calculates the direction and speed. This all works fine until I test on a mobile devices. About 2/3 when you throw an enemy they just drop because the speed is being set to 0, this especially happens when swiping very quick.
Is there a better way to calculate the speed and direction because of this?
Currently my control object to pick up and throw
looks like this:
Is there a better way to calculate the speed and direction because of this?
Currently my control object to pick up and throw
Code:
if(pick = 1) //Enemy picked up by clicking/tapping them
{
swpdir = point_direction(mxs,mys,device_mouse_x(0),device_mouse_y(0)); //swipe direction
swpspd = point_distance(mxs,mys,device_mouse_x(0),device_mouse_y(0))/1; //swipe speed
swpdist = point_distance(mxs,mys,device_mouse_x(0),device_mouse_y(0)); //swipe distance
with(a) //a is the enemy object selected
{
dir = other.swpdir;
dist = other.swpdist;
spd = other.swpspd;
}
if(device_mouse_check_button_released(0,mb_left))
{
pick = 0;
with(a)
{
dir = other.swpdir;
dist = other.swpdist;
spd = other.swpspd;
pick = 0; //no longer selected
drop = 1; //dropped
if(y < (sprite_height+25))
{
dzone = 1; //dropped high enough to destroy
}
motion_add(dir,spd);
}
a = noone; //no enemy selected
}
mxs = device_mouse_x(0); //x start loc
mys = device_mouse_y(0); //y start loc
}