Should I add a new event or add actions in same event?

Get help using Construct 2

Post » Mon Aug 07, 2017 9:26 am

Better new event or put everything for one event?
It now works in two versions, but I do not know if it affects something negatively.

Image
B
10
S
4
G
2
Posts: 197
Reputation: 2,382

Post » Mon Aug 07, 2017 9:51 am

If you have more than one Enemies: Destroy action in your code under different events then it can simplify your code to use "On destroyed".

Using "On destroyed" can also get around some problems with multiple enemies being destroyed in the same tick; if the "Add 1 to Killed" etc actions if are placed in the same event as the destroy action they would only be triggered once regardless of how many enemies were destroyed. Whereas "On destroyed" ensures that those actions trigger for each enemy.
B
21
S
9
G
4
Posts: 473
Reputation: 4,285

Post » Mon Aug 07, 2017 10:45 am

mekonbekon wrote:If you have more than one Enemies: Destroy action in your code under different events then it can simplify your code to use "On destroyed".

Using "On destroyed" can also get around some problems with multiple enemies being destroyed in the same tick; if the "Add 1 to Killed" etc actions if are placed in the same event as the destroy action they would only be triggered once regardless of how many enemies were destroyed. Whereas "On destroyed" ensures that those actions trigger for each enemy.


@mekonbekon
You said "On destroyed can also get around some problems"
Ok So if in this case many enemies are killed in same tick, I should have "add 1 to killed" in "On destroyed" or not. Of course I want add 1 killed for each enemy.
B
10
S
4
G
2
Posts: 197
Reputation: 2,382

Post » Mon Aug 07, 2017 10:48 am

Yes, if you want to add one per enemy it is best to have the "add 1 to killed" action on the "On destroyed" condition.
B
21
S
9
G
4
Posts: 473
Reputation: 4,285

Post » Mon Aug 07, 2017 3:07 pm

Burying a trigger that deep down in conditions for no apparent reason will bring you soon or later into problems. Because the trigger needs to discover the whole logic path up to the parent condition to find out if it is allowed to run its actions.

Better change that 'On destroyed' event to a top level event.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Aug 07, 2017 4:35 pm

@99Instances2Go

Good point, I hadn't noticed that it was a sub-event.
B
21
S
9
G
4
Posts: 473
Reputation: 4,285

Post » Mon Aug 07, 2017 6:10 pm

99Instances2Go wrote:Burying a trigger that deep down in conditions for no apparent reason will bring you soon or later into problems. Because the trigger needs to discover the whole logic path up to the parent condition to find out if it is allowed to run its actions.



Image
Better change that 'On destroyed' event to a top level event.

@mekonbekon
@99Instances2Go
Ok, but then i must add rows from this previous event yes? And then it would be a new event.
mean:

+ enemies < 0
+ system trigger once
enemies on destroyed - Add 1 to kill
Add 10 to PP
Sad set to invisible
B
10
S
4
G
2
Posts: 197
Reputation: 2,382

Post » Mon Aug 07, 2017 6:41 pm

Yes, move the Enemies|On destroyed event and its associated actions to be a top-level event rather than a sub-event and you'll be fine.
B
21
S
9
G
4
Posts: 473
Reputation: 4,285

Post » Tue Aug 08, 2017 7:04 am

mekonbekon wrote:Yes, move the Enemies|On destroyed event and its associated actions to be a top-level event rather than a sub-event and you'll be fine.

@mekonbekon
I tried make new event but I can't paste "trigger once" here.
Image
B
10
S
4
G
2
Posts: 197
Reputation: 2,382

Post » Tue Aug 08, 2017 8:25 am

You don't need to move those conditions. they should stay where they were before. You only need to move the on destroyed condition and its associated actions to be a main event.
B
21
S
9
G
4
Posts: 473
Reputation: 4,285

Next

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 34 guests