• 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 display separate text in instances of same object?

U

utku

Guest
I have an event that creates and places objects on a layer via;

instance_create_layer( <relevant x value>,<relevant y value>,"layer_block",obj_idleblock)

Those obj_idleblock objects has a square sprite, and a draw event that draws a text inside displaying the value from a global variable at that moment.

idleblock_value = global.block_value;
draw_self();
draw_text(x,y,string(idleblock_value));

My problem is that every time that global value changes, the text value displayed on all previous ones change to the newest value. So instead of having a pile of blocks that each display the value of the time they were created; I end up with a screen full of blocks that all display the same value, which keeps changing every time the value is updated.

I am sure there is a simple solution to this, but I couldn't find anything with search so far, so any help would be greatly appreciated.
 

PlayerOne

Member
The issue here is that your using a global instead of an object variable.

A global will affect all objects in the room, while a object variable will only affect the object in question.
 
Top