Does Family auto-pick instance after Create?

Discussion and feedback on Construct 2

Post » Wed Nov 25, 2015 4:48 pm

Say I have a Family Fruit with 3 similar fruit objects Apple, Orange, Pear. I use System.CreateObject(Apple) to create an Apple instance, will Fruit immediately pick that Apple instance so I can use subsequent code like Fruit.X = 100, Fruit.Y = 100, etc... ?

Right now I'm storing the UID right after the CreateObject and then doing Fruit.PickByUID after a set of conditionals. I'm hoping to clean up this code some if the subsequent Pick is unnecessary.

Thanks for your advice :-)
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Wed Nov 25, 2015 8:48 pm

no, it doesn't autopick, sadly. you have to do it next tick.
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
39
S
14
G
12
Posts: 617
Reputation: 9,297

Post » Wed Nov 25, 2015 9:07 pm

It's actually pickable at the next toplevel event too.
B
88
S
30
G
90
Posts: 5,113
Reputation: 60,837

Post » Wed Dec 02, 2015 4:25 pm

R0J0hound wrote:It's actually pickable at the next toplevel event too.


Yep, I'm doing this. It works fine. However, I'll always be on the lookout for any way to write less lines of code ;-)
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Wed Dec 02, 2015 7:58 pm

I can't test this at the moment, but can't you get around the "next top level event" limitation by using the "pick by UID" condition. If I remember correctly, you should be able to create the sprite (or whatever) instance, and then pick the family instance by the UID of the sprite instance.
B
58
S
17
G
8
Posts: 341
Reputation: 11,855

Post » Wed Dec 02, 2015 8:59 pm

zatyka wrote:I can't test this at the moment, but can't you get around the "next top level event" limitation by using the "pick by UID" condition. If I remember correctly, you should be able to create the sprite (or whatever) instance, and then pick the family instance by the UID of the sprite instance.


Yes I think you're right. This is what I'm doing. Pick by UID is the only pick that works immediately, in same event.. That I can see.
B
13
S
4
Posts: 280
Reputation: 1,573


Return to Construct 2 General

Who is online

Users browsing this forum: jaber4258, tetuan and 9 guests