Move towards Point/IMAGE_INDEX BUG HELP

R

RJb

Guest
So I have this code in my global left mouse down event.


move_towards_point(mouse_x,mouse_y,Accel);
var frame = 0
var direc = point_direction(x,y,mouse_x,mouse_y)
if (direc>=270) frame=0
else frame =round(direc/180)
image_index=frame

when my object goes to the that point the images change back and forth really fast. How do I fix this to keep the image from changing? i ONLY HAVE 2 IMAGES TOTAL.
 
S

Spencer S

Guest
I would guess that the code being shown here is executed every frame that the mouse is held down? If so, when the object gets to the point specified, the object actually bounces around minutely between x and y locations. It'll move 0.4pixels in the x direction, then reverse, and back and forth, which is why your image is swapping frames every frame of the game.

One way to fix this would be to include some sort of variable that is activated once when the image_index is changed, and then isn't deactivated until the mouse_button is released.

That's just one solution out of many, but from what I can gather, the issue that's causing the frames to switch rapidly will be fixed by implementing that variable.
 
Top