Creating the right object?

For questions about using Classic.

Post » Wed Nov 23, 2011 12:55 pm

Lets say blue is a family of 3 different objects

>Blue: private variable is 1
   - system: create object Blue

/\ Since it's a system action, this event would just create 1 random object from the family Blue, and not the object that has a private variable 1. But I want to create the family object that has a private variable 1.How can I achieve this?
B
6
S
1
G
1
Posts: 69
Reputation: 1,019

Post » Wed Nov 23, 2011 2:11 pm

Curious about this too... just been trying to solve it but can't find a way to pick a specific instance - it just picks anything from the blue family at random
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Wed Nov 23, 2011 2:16 pm

Well yeah. If blue consists of numerous objects and you create blue, how do you expect Construct to know which one you want? I'm surprised it even allows you to do that.

Anyway, just give the object with the value of 1 another value that tells it which 'blue' to create.

If blue's value=1 and the other value=Object 1 then create a specific object.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Wed Nov 23, 2011 3:38 pm

Another way would be to use a function. This is even more versatile. The right object will be created with any trigger, just by passing an id.

Here is a simplified example:
http://www.mediafire.com/file/ocwb64no0tctux0/SelectFromFamily.cap
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Wed Nov 23, 2011 5:51 pm

Very useful, thanks for that example. From a programming background, functions were the key to a lot of things but with the event structure of Construct I often forget that they're there
B
15
S
6
G
6
Posts: 103
Reputation: 2,968


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests