How do I ....Spawn the same sprite but give it a unique ID

Get help using Construct 2

Post » Wed Feb 08, 2017 7:31 am

Hi,

I currently have a game in development where I spawn a certain sprite every 10 seconds , this works fine but I want each sprite that is spawned to have its own unique ID.

So then I can, for example , see if one of the sprites collides with a certain object, that only that one is destroyed and not every instance of that sprite.

Can I make it so everytime the sprite is spawned it has its own unique reference or name.
Twitter - KcajjGaming
Youtube - KcajjGaming
Image
B
9
S
3
G
2
Posts: 17
Reputation: 1,736

Post » Wed Feb 08, 2017 8:20 am

Every sprite has already an unique ID. shortened as UID. You can retrieve it in the expression Sprite.UID

It is unique during run time. It can rearrange during designing, when you going to create/destroy sprites in layout editor.

You can also give a sprite an instance variable. Give it a accumulating value during run time. Or give it values in the layout editor.

Both are intensive used. But not (or very rarely) in the way that you mention.

Using the condition Sprite > 'On collision with another object' will PICK both (instances of) objects, and only those objects.
The actions work on the picked objects.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Feb 08, 2017 10:52 pm

Yeah , its just I have a sprite being duplicated every x Seconds, but if one instance of that sprite collides with an object , I want to destroy that sprite only and not other instances of it on screen :/
Twitter - KcajjGaming
Youtube - KcajjGaming
Image
B
9
S
3
G
2
Posts: 17
Reputation: 1,736

Post » Wed Feb 08, 2017 11:15 pm

That's how it works by default unless you have something funky going on in your events. Can you post your capx or a screenshot of the event sheet?
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Post » Wed Feb 08, 2017 11:25 pm

Never mind man ! Thanks for you help , ive worked it out now haha!
Twitter - KcajjGaming
Youtube - KcajjGaming
Image
B
9
S
3
G
2
Posts: 17
Reputation: 1,736


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 18 guests