How do I store UID of a created object ? [solved]

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello.

    I'm making a tetris game. And each time in a while , i got a spwaner creating "active" blocks to make pieces.

    But i need to keep track of each of the 4 blocks created while they are active (not lay on ground or inactive pieces) with unique IDs ...?

    How can i do that ?

    I know a bit how to use the pick by UID, or use the Sprite(UID).X .Y things etc... to act on them.

    But how do i store their IDs when the piece is created ?

    like i want to know exactly the UID of block created first, the second one, third, and last one. (all pieces got 4 blocks)

    Sorry if it' a noobish question. Searched the manual and forums, haven't found exactly.

    In other words : how can i store the UID of a created instance in a variable ? where's this option ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In what way do you want to keep track..

    would setting variables to the uid work?

  • Ok, here how i solved the thing...

    I created an instance variable called "block" to store wich one is 1/2/3/4 th block.

    And used a local 0 value variable that i reset each time a piece is created.

    After creating the piece, i used a "on create" event that add 1 to the local variable.

    And set the "block" instance variable to this local var.

    And now i have the number of each block created, and can use them separatly !

    "on created" events runs each time a sprite of the same type/object is created, this is what i needed to store their ID /number

    thanks a lot to this guide here : https://www.scirra.com/tutorials/361/un ... moke-trail

    Hope this could help other newscomers, this issue seems to have been asked many times.

    But haven't found the answer i needed till now.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)