0 Favourites

Accessing Object Instances Index IDs

This forum is currently in read-only mode.
  • 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.

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

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • I love You. <img src="smileys/smiley1.gif" border="0" align="middle" />

    Yeah, I was reading about loop index earlier today, but didn't really think about this.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
167 14,490
DMT2005's avatar
DMT2005
Unread hot topic
0 Favourites
0-indexed vs 1-indexed
41 5,730
Horrendous Games's avatar
Horrendous Games
Unread hot topic
0 Favourites
[Plugin] instance bank2
85 18,368
rexrainbow's avatar
rexrainbow