Wipe clean a layer

Get help using Construct 2

Post » Sun Nov 04, 2012 3:55 pm

Is there a way to clear a layer?

For example; I have a projectile that spawns a trail every millisecond on a specific layer.

A second projectile can be launched using the first trail as a reference.

When the second projectile hits a target, the first trail disappears but leaves the second trail up.

It cycles for third projectile, fourth, fifth, etc.

Think of the Angry Birds.

The only thing I can think of is having alternating layers, where they alternatively get wiped clean for re-use.

Any idea of how to do this? Or am I going about this wrong?


B
31
S
6
G
4
Posts: 160
Reputation: 5,998

Post » Mon Nov 05, 2012 6:15 am

Can you put a Fade function on the trail so that after a set amount of time it fades out and also check the destroy after fadeout so you dont accumulate artifacts...Try to make sure the trail is withing a Family and apply the fade to the Family instance Behaviors..that way it will be the same for every trail
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
30
S
11
G
8
Posts: 313
Reputation: 7,360

Post » Mon Nov 05, 2012 11:53 am

Your alternating layers idea could work, you'd just need a Global Variable to keep track of the layer the trail sprites are spawned on and then you could have an event like this to clear them:

Conditions:
System->For Each Trail_Sprite
Trail_Sprite->Is on layer LAYER_VARIABLE

Actions:
Trail_Sprite->Destroy

Sub-Event:
Conditions:
System->Compare Variable->LAYER_VARIABLE = 1

Actions:
System->Set Value->LAYER_VARIABLE = 2

Else:

Actions:
System->Set Value->LAYER_VARIABLE = 1


An alternative to using different layers would be to give your trail sprites an alternating instance variable, the event to clear them would be pretty much the same but instead of checking what layer the sprites are on, you'd just check their instance variable
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
27
S
7
G
4
Posts: 314
Reputation: 4,928


Return to How do I....?

Who is online

Users browsing this forum: makkancs, Matthew de and 36 guests