[Suggestion] Pick any object by UID

Discussion and feedback on Construct 2

Post » Tue Mar 03, 2015 11:58 am

@Ashley

I thought it would be very helpful to have the following system event:

- pick any object by UID

This will allow to write more abstract an reusable code.

Right now picking by UID is bound only to a specific object.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue Mar 03, 2015 12:14 pm

Picking only a known object by UID makes sense as otherwise how do you know what parameters are available? What behaviours, what effects, what instance variables? How do you code for that?
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Tue Mar 03, 2015 12:17 pm

If you pick an instance from an object type you don't know in advance, how would you make an action to modify that instance? To make an action you have to pick a specific object type.
Scirra Founder
B
397
S
236
G
88
Posts: 24,420
Reputation: 194,549

Post » Tue Mar 03, 2015 12:55 pm

@Ashley
Only use universal actions like destroy, set position, move at an angle, spawn another object, set visible etc.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue Mar 03, 2015 1:10 pm

What if that object was an array?
Image ImageImage
B
169
S
50
G
173
Posts: 8,319
Reputation: 110,282

Post » Tue Mar 03, 2015 1:21 pm

:)) Ok, there could be following solutions:

1) extra condition to check for an object type, which filters out actions specific to this object
2) limit pick any object by UID to sprite objects and call it "Pick any sprite object by UID", as it's the most used object type.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue Mar 03, 2015 1:26 pm

The work around now would be to use a global variable.
Like if globalvariable = 1 pick all these types, =2 all these other types.
Image ImageImage
B
169
S
50
G
173
Posts: 8,319
Reputation: 110,282

Post » Tue Mar 03, 2015 3:54 pm

@xoros
The current workaround is to put every single sprite object into a BaseSprite family and every tiled background into a TiledFamily, then pick by UID. Having these base classes is useful in general especially when writing helper functions.
B
31
S
7
G
8
Posts: 232
Reputation: 6,274

Post » Tue Mar 03, 2015 5:54 pm

An extra condition to check the object type means you've just reinvented the ordinary "pick by UID" condition!

To pick any instance from a plugin type, you can also use families.
Scirra Founder
B
397
S
236
G
88
Posts: 24,420
Reputation: 194,549

Post » Tue Mar 03, 2015 8:46 pm

@cacotigon
yep, that's a usefull technique.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests