Accessing Object Instances Index IDs

For questions about using Classic.

Post » Mon Jan 30, 2012 6:50 am

I've been trying to find a way to access the order information of objects. Naturally, in which order they have been created, and have them carry their information in each instance. As in, this is the first instance, that has been created of this object, this one the second, the third, etc. ... .

The only ways I could think of are too complicated, when I feel like there is surely an easy way.

I would do it with a global variable, and that is what I don't like, to have something external like that. Since, if different Objects get plentysome, I'd end up with loads of global variables just for ordering the instances of each Object.

I would basically do something like this:

We have:
+ globalvar('IDCounter') = 0
+ SpriteObject
+ SpriteObjectVar('IndexID') = 0

We do:
+ For Each SpriteObject (Ordered by SpriteObject.UID - Ascending)
-> Add +1 to global('IDCounter')
-> SpriteObject.SetValue('IndexID') = global('IDCounter')

Thank You in advance.Shindoh2012-01-30 06:51:42
B
3
G
1
Posts: 70
Reputation: 615

Post » Mon Jan 30, 2012 7:10 am

It just so happens that for each goes through instances based on creation.
So for each sprite set private variable "myid" to loopindex should suffice.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Jan 30, 2012 7:14 am

I love You.
Yeah, I was reading about loop index earlier today, but didn't really think about this. Shindoh2012-01-30 07:15:31
B
3
G
1
Posts: 70
Reputation: 615


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest