Combining And and Or blocks?

Get help using Construct 2

Post » Tue Sep 06, 2016 1:29 pm

Message: Animiles can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hello people,

I'm currently on day 1 of a 3 day game jam, and I have a little problem with the event sheet.
I have a system where you loose one Cookie (point) when you hit something. I have a geiser, which will trigger the code when the player hits it And the geiser is on. But the same system also has to work when the player hits other enemies. In the screenshot linked below you can see the part of the eventshet I'm talking about.

What I want is:
On collision with Particles
AND
is GeiserOn
OR
On collision with Enemy1

Is there any way to make this happen? Not only is this useful here, but I can use that information in later projects too. I have ways of changing my sheet to make this possible (turning the collision box on and off) but I mostly want to know how I can do this in my initial way since it looks like something I'll encounter again very soon.

Thanks in advance! :)

http://puu.sh/r1QZT/329b35c2c4.png
B
3
Posts: 2
Reputation: 179

Post » Tue Sep 06, 2016 1:44 pm

"On collision" is a trigger, which you can't use OR on. Just have the two separate events (AND works in the first case) and call a function that does the actions.
ImageImageImage
B
71
S
21
G
229
Posts: 3,687
Reputation: 128,338

Post » Tue Sep 06, 2016 1:49 pm

Message: Animiles can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I fixed this by adding a GeiserCollision sprite without opasity, and I changed the scaling when the particles turn on or off. Here is a screenshot of how I fixed it: http://puu.sh/r1RS2/ebc08a757c.png
But i still want to know how I can do it the way I first came up with since I probably need it in the future.

@blackhornet, I don't really know how I should do that. Could you write a little example please?
B
3
Posts: 2
Reputation: 179

Post » Tue Sep 06, 2016 1:57 pm

On collision (sprite) with Particles creates a picklist containing That Sprite and That Particle.
Any other following pick condition in the same event and in sub events will start to pick from that picklist (containing That Sprite and That Particle)

Hence, that sprite that collides with Enemy1 is not present in that picklist (at this point the previous picklist).
Whatever the outcome of the condtion (true or false) the actions have no object to run on.
Conclusion: you have to start picking from scratch for the second condition.

Conditions:
On collision with Particles
is GeiserOn
Actions: whats needed to be done

New condition (picking from scratch)
On collision with Enemy1
Actions: whats needed to done

This ofcours leads to re-using the same actions and to more code. Get a long with that using a function.
So.

Event:
On collision with Particles
is GeiserOn
Action: call function with parameters the UID of That one sprite and That particle

New event (picking from scratch)
On collision with Enemy1
Action: call function with parameters the UID of That one sprite and That particle

New event.
On function
Pick Sprite by UID ... do your thing
Pick particle by UID ... do your thing.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Sep 06, 2016 4:21 pm

You could make the code like my example below. :mrgreen:

https://www.dropbox.com/s/prc6xgiaeswda ... .capx?dl=0

Explained

1. There are 3 characters:

a. Player (Sprite)
b. Enemy (Sprite)
c. Geyser (Particle)

2. Player will lose a cookie only when it collides with Enemy or Geyser when the Geyser is turned on.

3. Geyser gets automatically activated in every 5 seconds and lasts for 3 seconds.

4. Enemy is equipped with a Line of Sight behavior, and chases Player when it approaches closely.

If you want the enemy to trigger a cookie loss even when the geyser is turned off, then change Line 3's [System] -> [GeyserIsOn] to 0 and add another [System] -> [GeyserIsOn] to 1 below.

Then you'll notice [System] -> [GeyserIsOn] is no longer needed.

Then you can just add [System] -> [Subtract 1 from cookies] beside the initial [OR] statement.

I arranged the code this way for you to learn an easier and better way of arranging conditions. :mrgreen:
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Wed Sep 07, 2016 5:14 pm

On collision with Particles
OR
On collision with Enemy1

Branch
is GeiserOn

Action
B
9
S
3
Posts: 102
Reputation: 987


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], fearfulelephants and 25 guests