a little request

Discussion and feedback on Construct 2

Post » Sun Sep 09, 2012 8:09 pm

it would be super helpful if I could compare objects' UIDs.

imagine you have a sprite "foo" and sprite "bar" pinned to "foo" and you want to destroy "bar" on "foo" destroyed. currently thr only ways to do that is to store "bar"'s UID in "foo"'s instance variable "barsuid":

on foo destroyed
pick bar by uid = foo.barsuid
-- destroy bar

or to loop through all "bar"'s on destroying "foo":

on foo destroyed
- for every bar
- system->compare (bar.pinned_object_uid == foo.uid)
--> destroy bar

this addition would change not so much, but it would be clearer:

on foo destroyed
foo.uid == bar.pinned_object_uid
--> destroy bar

hope it would not be too much to ask :)ranma2012-09-09 20:12:37
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Sun Sep 09, 2012 8:24 pm

you can also store the an instance variable of foo too.

http://www.scirra.com/tutorials/361/understanding-uid-iid-health-cards-and-rocket-smoke-trail

If you place the bar on the screen, fill the instance variable "ID" with your desired ID, or, on creating it, set its ID on the same event.
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,209
Reputation: 18,357

Post » Sun Sep 09, 2012 9:12 pm

yea, but the thing is, say, I have a sprite with 100 pinned objects to it, and i want to destroy all of them when sprite is destroyed - ergo 100 instance variables? :) there are messy and could be easily dropped with this "compare uid" condition, also, there's "pick by uid" condition which is similar, but other way around, right?
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Sun Sep 09, 2012 9:19 pm

you're right, that was only another way to do it. Also, you can use family. Place all the pinned objects inside a new family for that object and then destroy the family.

Many ways.
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,209
Reputation: 18,357

Post » Sun Sep 09, 2012 9:48 pm

well yea, but every way is kinda messy, and this new addition would make things very clear I think :)
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Sun Sep 09, 2012 10:03 pm

You're asking for an event which says "Pick the instance of Bar whose Bar.PinnedUID expression matches the currently picked Foo UID". This is not easy to express in Construct 2's event system in a single condition. It goes against the typical way conditions work. To be honest I don't see anything wrong with the first or second examples. I guess containers would help here as well, they're still on our todo list.Ashley2012-09-09 22:03:50
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,554

Post » Sun Sep 09, 2012 11:27 pm

if containers would help, and if they are on todo list, that's enough for me :)

cheers.
B
81
S
50
G
10
Posts: 555
Reputation: 13,009


Return to Construct 2 General

Who is online

Users browsing this forum: TRMG, Zonacas and 2 guests