Sprites in the GameMaker Language
When it comes to making games with animation, it is extremely common for the animation to need to stop or change when an event happens. For example, the player pressing the right arrow key may make the game change the character's animation to a running animation.
You will learn to do this through programming using GameMaker Language in a new object.
Every object in GameMaker has a set of variables that allow users to control what sprite an object has linked to it, as well as the animation speed, current frame, and more.
Setting an object's sprite
The
sprite_index
variable defines which sprite the object currently has set to it. Changing this variable will change the object's sprite.
The following is the example code:
sprite_index=spr_player;
Getting the width and height of a sprite
The sprite_width
and sprite_height
variables return the width and height of the sprite currently linked to an object. This becomes useful when positioning text or other things around...