hspeed

Drag & Drop equivalent: GM005

 

Reverse hspeed - D&D equivalent: GM008 (See below)

 

Example:

hspeed = 5;

 

hspeed holds the horizontal speed of the object. A plus number (as in the example above) means the object is moving right, a minus number (hspeed = - 4) means the object is moving left. This is useful if you want an object with one image that you want to turn left and right (to save filesize), like an enemy on a platform game that moves left & right, you can check the hspeed of the object, if it's less that 0, it's moving left, if it's greater than 0, it's moving right.

 

// Flip the image so it's looking in the right direction

// GM V6.x

if hspeed < 0

{

image_xscale = 1;

}

else

{

image_xscale = -1;

}

 

You can also use hspeed to reverse an objects horizontal motion.  For example, putting the following code inside an enemies collision with something:

 

hspeed = -hspeed;

 

Revision #3