Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Gamemaker Essentials

You're reading from   Gamemaker Essentials Learn all the essential skills of GameMaker: Studio and start making your own impressive games with ease

Arrow left icon
Product type Paperback
Published in Mar 2015
Publisher
ISBN-13 9781784396121
Length 154 pages
Edition 1st Edition
Arrow right icon
Toc

Variables

As in any programming language, the first things you should know is how to initialize different types of variables and how each variable type can be used. In GameMaker, there are four main types of variables: instance, local, global, and arrays.

Instance variables

An instance variable is one that is local to the instance it is initialized in. This means that it is not directly accessible in any other instance within your game and must have the instance ID for it to be referenced from outside of the instance it is created in.

To initialize an instance variable, type its name, the equals sign (=), and then its value. The value can be either a real or a string. If the value is a string, then the text must be enclosed in quotation marks.

The following is a sample of two instance variables being initialized in GameMaker:

Instance variables

Once these variables have been initialized, they can be used in any event of the object.

Local variables

A local variable is a variable that is local to the code block or...

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 €18.99/month. Cancel anytime