Master Slave Instances? (Solved with .capx)

Get help using Construct 2

Post » Wed Mar 05, 2014 3:48 pm

Hi!

I hope my jpg explains the issue im having.
I truly need some help with this, as i ran out of ways to tackle this.

Basically what i need is: to set multiple masters, and then connect multiple slaves to a single master.

Extra info:
All sprites are already on screen (so no spawning is involved here).
And all are instances of 1 particular sprite.
The image explains it best i think.

I really hope someone out there can help me with this.

Image

Kind Regards
Savvy001

"Sorry if i double posted this "how to" but with the last one, i did not explain it correctly so it went overdue.
Last edited by Savvy001 on Wed Mar 05, 2014 11:00 pm, edited 1 time in total.
B
59
S
21
G
14
Posts: 779
Reputation: 13,927

Post » Wed Mar 05, 2014 3:56 pm

Still the same solution:
Create a variable Int: lastMaster
Create a family and set up two instance variables:
Boolean master
Int connectedToMaster

Select master:
On touched object Family
set Family master to true
set lastMaster to Family.UID

Select slaves:
On touched object Family
set connectedToMaster lastMaster
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Wed Mar 05, 2014 4:01 pm

@Rabenmutter

Thanx for the reply, but the problem is that i cant pick a instance and compare it to another instance to be able to connect one to the other.
I simply cant find a option for that in construct.
So by that i dont truly understand your solution.
Probably because i am not fully aware of possibilities.
B
59
S
21
G
14
Posts: 779
Reputation: 13,927

Post » Wed Mar 05, 2014 4:36 pm

Now i am succesfull in setting a master and a slave.
But connecting them via a pin behavior or otherwise is currently the problem.

I am trying:
Pick by comparison/pick by evaluate/pick by instance.
But non of these let me pick the slave instance so that then i can pin them to the master instance.

Normally this would be no problem between sprites "non same instance".
Then i would state, pick sprite (a) pin to sprite (b).
B
59
S
21
G
14
Posts: 779
Reputation: 13,927

Post » Wed Mar 05, 2014 5:40 pm

Fixed it!

It has been a ride but now i works just perfectly.
Thanx!!!
B
59
S
21
G
14
Posts: 779
Reputation: 13,927

Post » Wed Mar 05, 2014 6:41 pm

@Savvy001, would you mind posting your solution so that others can also learn how to do this?
B
20
S
4
G
1
Posts: 185
Reputation: 2,563

Post » Wed Mar 05, 2014 10:58 pm

Here u go!

http://www.vrijetoekomst.nl/Apps/MasterSlave.capx

Click on set Master button and then a sprite to set a master.
Then click on set Slave button, and then a other sprite to let it rotate around the master.
When u then click on the set Master button again u can set a second Master/and third etc.

Just remember that after u have set the master, the slaves u will set are connected to that master.

u can also click on set Master and then a previous master u already set to start adding slaves to that specific master.

The slaves are drag & drop, and the more distance u put between the slave and the master, the slower the rotation of the slave around the master.

Have fun!
B
59
S
21
G
14
Posts: 779
Reputation: 13,927

Post » Thu Mar 06, 2014 6:24 am

I'm glad you found a solution and I hopefully could help you a bit :)
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Thu Mar 06, 2014 7:07 am

Yes u did.
And thank u for that!
B
59
S
21
G
14
Posts: 779
Reputation: 13,927

Post » Thu Mar 06, 2014 7:51 am

You really should avoid these Foreach Loops. They are triggered every tick and will make your games performance very poor. Is it necessary to drag n drop the slaves?
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev and 30 guests