• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How to use "variables" & "creation code" in the instance menu?

Sabnock

Member
i use this in the room editor to give individual instances of the same object individual creation code or variable values

if you use the variable definition creator in the object creation dialog instead of setting up your variables in the create event it allows you to modify them in the room editor so you can have for instance different animation speeds, scales, movement direction etc.

double click on the instance whilst in the room editor to access these options.
 
A

Annoyed Grunt

Guest
The optimal way to use them is to use the variables menu to define variables that you intend to set in the room. In your create event you then do calculations and other setup operations which are supposed to be "hidden" from view. Lastly, if need be, you can insert extra code in the Creation Code script.

Notice that this is exactly the order these operations are executed.
  • Variables from the variables menu are created.
  • Create event is executed.
  • Creation code is executed.
So make sure you are not overriding your instance variables in your create event.
 
K

krugen

Guest
The optimal way to use them is to use the variables menu to define variables that you intend to set in the room. In your create event you then do calculations and other setup operations which are supposed to be "hidden" from view. Lastly, if need be, you can insert extra code in the Creation Code script.

Notice that this is exactly the order these operations are executed.
  • Variables from the variables menu are created.
  • Create event is executed.
  • Creation code is executed.
So make sure you are not overriding your instance variables in your create event.
what is the difference between creation code and creation event?
 

Sabnock

Member
what is the difference between creation code and creation event?
Nothing.creation code is effectively the same. It is just more versatile when used in the room editor as it allows you to manipulate each instance of the same object.


There is loads of content on this subject on your friend Google.
 
Last edited:

NightFrost

Member
Those are most useful when you have a small number of instances in the room editor that each needs to be uniquely identified. (With large numbers it becomes more efficient to write code to do that instead of manually clicking and writing to each). A good example would be a top-down adventure game where there's several doors in each room leading to other rooms. You can use these features to tell each door where it should lead and where player should spawn in the next room.
 
A

Annoyed Grunt

Guest
what is the difference between creation code and creation event?
Creation code is executed right after the Create Event code. Code in your Create Event is executed for all instances, while creation code is only executed for one instance.
 
Top