move_wrap

Wraps the player around the room if relevant.

Syntax:

move_wrap(hor, vert, margin);


Argument Description
hor Whether to wrap horizontally (true) or not (false).
vert Whether to wrap vertically (true) or not (false).
margin How far outside the room, in pixels, the object must be to initiate wrapping.


Returns: N/A


Description

This function will automatically "wrap" an instance that has left the room on either the horizontal or vertical (or both) axis. You can specify a margin outside the edges of the room for this to occur, and when the instance has travelled outside of that margin GameMaker: Studio will automatically wrap it back into the room at the other side. Note that the instance must have a speed for wrapping to work, because the direction of wrapping is based on the direction of the motion.


Example:

move_wrap(true, false, sprite_width);

This will make the instance wrap horizontally but not vertically, when it is over its own sprite width outside of the room.


Back: Moving Around
Next: direction
© Copyright YoYo Games Ltd. 2018 All Rights Reserved