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

Get help using Construct 2

Post » Mon Nov 09, 2015 7:14 pm

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 ?
Last edited by WeneW on Mon Nov 09, 2015 8:10 pm, edited 1 time in total.
twitch.tv/neozoom/
Dev stream from time to time !
@FireCamp_games <-- twitter
B
6
S
2
G
2
Posts: 52
Reputation: 969

Post » Mon Nov 09, 2015 8:10 pm

In what way do you want to keep track..
would setting variables to the uid work?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Nov 09, 2015 8:10 pm

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.
twitch.tv/neozoom/
Dev stream from time to time !
@FireCamp_games <-- twitter
B
6
S
2
G
2
Posts: 52
Reputation: 969


Return to How do I....?

Who is online

Users browsing this forum: varr, Yahoo [Bot] and 3 guests