How do I Isolate a specific instance of a sprite?

Get help using Construct 2

Post » Mon Feb 02, 2015 2:08 pm

Hi,

I was just wondering if there was a way of picking on a specific instance of an object. Say for example you had 6 bad guys on screen and you wanted to make one randomly glow to signal when the player can destroy him, all 6 are just copies of the same sprite so is there anyway to isolate the individual instance(s)? There is prob an easy solution staring me in the face sorry lol!

Regards
Joel
B
7
S
1
Posts: 61
Reputation: 567

Post » Mon Feb 02, 2015 2:10 pm

You can pick by nth instance (a System expression), a.k.a IID, and use random( sprite.count) to pick.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Feb 02, 2015 4:33 pm

codah wrote:You can pick by nth instance (a System expression), a.k.a IID, and use random( sprite.count) to pick.


Thank you I will give this a shot, I always assumed Sprite.Count would just use the maximum amount of that sprite I.e the number of that sprite it counts as created. Will let you know how it works out, thank you very much for your reply.
B
7
S
1
Posts: 61
Reputation: 567

Post » Mon Feb 02, 2015 8:31 pm

RandomOutput wrote:
codah wrote:You can pick by nth instance (a System expression), a.k.a IID, and use random( sprite.count) to pick.


Thank you I will give this a shot, I always assumed Sprite.Count would just use the maximum amount of that sprite I.e the number of that sprite it counts as created. Will let you know how it works out, thank you very much for your reply.


It is the number of currently created instances of an object, so if you had more than 6 instances (some off-screen), but only wanted to pick from the ones on-screen, then you would first pick by the 'onscreen' expression, then by perhaps by an expression where 'Sprite.IID = random(Sprite.PickedCount)'.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Feb 02, 2015 9:56 pm

codah wrote:
RandomOutput wrote:
codah wrote:You can pick by nth instance (a System expression), a.k.a IID, and use random( sprite.count) to pick.


Thank you I will give this a shot, I always assumed Sprite.Count would just use the maximum amount of that sprite I.e the number of that sprite it counts as created. Will let you know how it works out, thank you very much for your reply.


It is the number of currently created instances of an object, so if you had more than 6 instances (some off-screen), but only wanted to pick from the ones on-screen, then you would first pick by the 'onscreen' expression, then by perhaps by an expression where 'Sprite.IID = random(Sprite.PickedCount)'.


It worked a treat, thank you so much! I knew it would be something simple, glad you stopped me from my over complicated approach. :)

Regards
Joel
B
7
S
1
Posts: 61
Reputation: 567


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests