How do I retrieve the value of any clicked or touched sprite

Just started using Construct 2? Post your questions here

Post » Thu Aug 21, 2014 11:08 am

Hi, a question of an enthusiast newbie. I hope this first post is in the right place. I hope also somebody has an solution for me. I can't find it myself yet.

This is the situation:
I have many different sprites with different names and different values stored in their instance variables (numbers).
I know how to retrieve the value of every sprite separately by name, but I thought it would be easier, nicer and faster to make a function that I can use for all the different sprites with their different names and values to let them do the same Action.
But how can I retrieve the value of that clicked or touched sprite, getting it's value only because it's clicked or touched, to use in a function?
Or maybe that's not possible? Or is it simple and I can't find it?
All help will be very much appreciated, thanks a lot in advance.

Philip
B
5
Posts: 14
Reputation: 260

Post » Thu Aug 21, 2014 12:37 pm

Sounds like you would need to put all your different sprites in a single family, have this family have a common family instance variable and each instance of each object type having a different value.

This way "Touch: On touched FamilyName" will allow you to get FamilyName.InstanceVariableValue. (I hope this makes sense).
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
296
S
119
G
96
Posts: 7,332
Reputation: 71,306

Post » Sat Aug 23, 2014 7:54 pm

Thanks for the quick answer. Could not find out, how to deal with it, so solved the problem by copy and pasting a lot. Works fine, just more work.
B
5
Posts: 14
Reputation: 260


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests