Create Family Object with Multiple Instances

Get help using Construct 2

Post » Sat Feb 02, 2013 1:37 am

I'm looking a quick solution how to create a family object once time, i have like 7 different instances are part of this family.

Each instance has instance variable like name and X & Y positions.

On Start Layout:
System -> -Create object MyFamily1
MyFamily1 -> -Set Animation to MyFamily1.Name
MyFamily1 -> -Set Position to (MyFamily1.InstanceX, MyFamily1.InstanceY)

Observed result was it created only one instance, not multiples...


Thanks!
              Joannesalfa2013-02-02 01:40:11
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sat Feb 02, 2013 2:16 am

Seems that C2 creates 1 instance because there's only 1 event making it spawn , I recommend using functions , seems like families aren't for spawning ...
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sat Feb 02, 2013 2:27 am

[QUOTE=Whiteclaws] Seems that C2 creates 1 instance because there's only 1 event making it spawn , I recommend using functions , seems like families aren't for spawning ...[/QUOTE]

@Whiteclaws I know. It's already using functions.
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sat Feb 02, 2013 2:31 am

Uh :D , My bad , could you give me some examples ?

I meant that you should make a function "family"

Add all the spawning ( Needs to be separate events ) in 1 function and call it when you need to spawn the many objects
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sat Feb 02, 2013 2:55 am

@Whiteclaws http://dl.dropbox.com/u/76227787/MultipleInstancesUnresolved.capx ?

The result looks pretty weirdJoannesalfa2013-02-02 02:55:47
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sat Feb 02, 2013 4:15 am

It won't work like this because you are creating sprites with
Color = ""
PosX = ""
PosY = ""
ID = ""

In your example you are refering to sprites from different layout. But on your current layout Sprite1 have all variables set to "".
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Sat Feb 02, 2013 5:07 am

@shinkan Yes i noticed, so don't you tell me what we should resolve this issue?
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sat Feb 02, 2013 11:04 am

How to pick the instances from another layout?
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sat Feb 02, 2013 1:00 pm

I'll try and resolve it ....
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sat Feb 02, 2013 1:08 pm

I don't think You can.
one of the solution would be to specify somewhere all attributes for variables

Family1.id = 1 - > set Color = "blue"
                   set PosX = "123"
                   set PosY = "321"

Family1.id = 2 - > set Color = "red"
                   set PosX = "567"
                   set PosY = "765"
...
That way family objects with corresponding id number will always have this values.

I'm not at home at the moment so I can't check for other possibilities.
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests