• 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!

Mass controlling instances

6

66Gramms

Guest
Hello!
So i'm making a level select screen where will be 90 levels but always 30 of them on display... (actually there are 30 instances) So i make the instances in a cycle and there i do it like this:
Code:
instance = instance_create(x, y, obj_level_select);
instance.level += rise //Level is a variable inside the object that is used to display the lvl number
rise++;
So this way i have levels from 1 to 30 lined up perfectly. but when i want to "change page" in the game i actually just want to change the instances' level variable by +1/-1
to do this all the instances should have different id. I know it could be done with an array but they told me there is a better way to do that. can you please help me about how to give all of them a different id and not all of them are going to be "instance" without using arrays?

if i don't do this just type like obj_level_select.level++ then all the instances will change to the same value (2) then increase together. Thanks in advance
 

Attachments

TheouAegis

Member
The reason this doesn't work

obj_level_select.level++

is it counts as a read operation. It basically means

obj_level_select.level=obj_level_select_0.level+1

So all instances are set based on the value of one.

with obj_level_select level++

Do that.
 
6

66Gramms

Guest
This is working, thank you ^^ I know why it didn't work i just didn't know how to make it work :D Also i realized i need to add 30 to them :D
 
Top