How do I pick the last instance created of a certain sprite?

Get help using Construct 2

Post » Fri Jun 10, 2016 12:31 am

Message: djohoe28 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I found a relatively relevant answer - https://www.scirra.com/forum/pick-last-instance_t69019 but it still didn't solve it for me.

Very basically I'm making a "visual array" of a certain sprite and I need the location of the last created instance of the sprite to do it, pretty much.

Please and thank you, and of course, if this belongs in Beginner's Question, go ahead and move it :D
B
7
Posts: 11
Reputation: 283

Post » Fri Jun 10, 2016 2:27 am

Using the pick nth instance with Sprite.count-1 should do it.
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Fri Jun 10, 2016 3:39 am

@djohoe28
Oh, ROJOhound beat me too it! I was going to suggest that, as well as saying you could also use "Pick top instance" because the last one created would be the highest in the z-order (unless you manually change it).

You could also save the UID in a global variable every time you create an instance. Then you have that available any time you need the sprite without having to make C2 loop through all the instances.
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Mon Jun 13, 2016 2:44 am

...without having to make C2 loop through all the instances.

The pick nth instance doesn't loop through all the instances, it just picks the instance directly.
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Sun Jun 19, 2016 3:39 pm

R0J0hound wrote:Using the pick nth instance with Sprite.count-1 should do it.


Sorry, I forgot to write back - thank you very much, that's -just- what I needed :)
B
7
Posts: 11
Reputation: 283


Return to How do I....?

Who is online

Users browsing this forum: marcinkowski, Yahoo [Bot], zenox98 and 26 guests