Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Gamemaker Essentials

You're reading from  Gamemaker Essentials

Product type Book
Published in Mar 2015
Publisher
ISBN-13 9781784396121
Pages 154 pages
Edition 1st Edition
Languages

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}