Change Families

Get help using Construct 2

Post » Mon Jan 23, 2012 11:42 pm

Hi guys!

Just wondering if there's a way for an item to change families during runtime.

Say for example I want a circle to move around the screen and bump into another circle... the player would then lose control of the first, and start controlling the second. I could do this with 1 or two, but say I want to be able to do this with hundreds of circles. I would have a code that reads:

If family.control touches family.noControl then change family.control to family.noControl and change family.noControl to family.control.

Hmm... confused myself there. In any case. Anybody got an idea on whether this is possible, and if so, care to share how?

I can figure out how to have the objects take control of one another like a zombie mode (touch gives player control over additional objects until you're controlling all 100), but I do not know how to have it so you only control 1 at a time.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Mon Jan 23, 2012 11:47 pm

Also, another quick question... how does families instance variables work? I can't seem to set any...
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Tue Jan 24, 2012 6:18 am

create a boolean 'controlled' in your circle object with default false except for the one you want to control at start of layout

And then if circle collide with circle, toggle 'controlled'

B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Jan 24, 2012 2:01 pm

Thanks Yann, but that doesn't seem to work with families. If I have lots of different items all in the same family, I want to have the code:

If family collide with family, toggle 'controlled'

but it doesn't look like it works just yet. I would have thought I'd see all of the variables that appear within the sprites in the family.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Tue Jan 24, 2012 2:12 pm

You dont need to use families.

If you have a instance boolean called controlled then compare the boolean when arrow is down ect then if the boolean is set to false then you cannot controll it, And set the boolean to the other one true..
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Tue Jan 24, 2012 7:05 pm

Thanks for replying smitchell!

I'm talking about potentially hundreds of different objects. Is it possible to set it up this way? Will I have to set up events for every single item?

If sprite1.boolean1 = true - activate control
If sprite2.boolean1 = true - activate control
etc,etc,etc

Can families have variables? The option is there, but it's always inaccessible.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Tue Jan 24, 2012 7:31 pm

I don't know about your game but I'm pretty sure you can put all your potentially hundreds of different objects in one only sprite.
But to be sure it would be good to explain a bit more about your game.

Also variable for families... Ash is probably working on it. Families are pretty new.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Jan 24, 2012 8:14 pm

I see... families also doesn't work with physics.

http://dl.dropbox.com/u/50465867/GravTest.capx

I wanted to set it up so if an object touches another one, it would swap control to that one... but instead of the 'move forward' that is currently set up, it would use forces with physics.

Am I going to have to wait a bit longer for the additional feature?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Tue Jan 24, 2012 8:18 pm

Again, why don't you put all your object in different animation frame of one only sprite and use a bolean to switch control on and off ?
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Jan 24, 2012 8:29 pm

I'm not sure how that would work... some of the items I need to control will be 'chained', attached or linked in some way to other objects. I would have to have an event setting the animation frame at start, wouldn't I?

Suppose it could work... but again I'd have a lot of events which I'm trying to cut down on.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests