Simplifying my code

Get help using Construct 2

Post » Tue Nov 20, 2012 2:55 pm

Hi All

I would like to simplify this code, so as I increase the number of instances of the BuildingFamily I don't have to keep adding additional code. I know there is probably a really easy way to do this, but I keep going around in circles.

A quick summary of what it does.
As the player nears a building, the facade fades to reveal the inside.



I would be greateful for some help.

Cheers

Howard
B
19
S
2
G
1
Posts: 24
Reputation: 3,597

Post » Tue Nov 20, 2012 3:28 pm

[code]+System: TowerSmall.X-Basket.X <= 300
+BuildingFamily: Number = TowerSmall.Number
-> BuildingFamily: Fade: start fade[/code]

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

Post » Wed Nov 21, 2012 5:46 pm

Hey thanks Yann for the reply, but sadly no joy
I tried a whole bunch of iterations of that and it only seems to work if I specify each one individually (see top).
B
19
S
2
G
1
Posts: 24
Reputation: 3,597

Post » Wed Nov 21, 2012 7:07 pm

This should behave the same as your events:
[code]+for each BuildingFamily
+System: TowerSmall.X-Basket.X <= 300
+BuildingFamily: Number = TowerSmall.Number
-> BuildingFamily: Fade: start fade[/code]

The "for each" would not be needed if there was only one instance of TowerSmall.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Wed Nov 21, 2012 8:49 pm

That's it! Thanks guys, working perfectly now.
I can apply that to a lot more of my events too!

Cheers

Howard
B
19
S
2
G
1
Posts: 24
Reputation: 3,597


Return to How do I....?

Who is online

Users browsing this forum: makkancs and 23 guests