"Else" VS Invert

Just started using Construct 2? Post your questions here

Post » Tue Jul 26, 2016 3:52 pm

I really am a new in Construct 2. :mrgreen:
I am confused using "Else" vs Inverting condition. What is the difference between those 2? :roll:
thx
B
10
S
3
G
1
Posts: 12
Reputation: 1,008

Post » Tue Jul 26, 2016 4:01 pm

The event with Else will only run if the previous event did not run. Very useful for toggles.

Invert is usually for picking like usual.

For example, if you had is overlapping, and inverted is not overlapping, both these will run and the relevant actions applied to the objects that are or are not overlapping.

If you had overlapping, then else, the else event would only run if nothing was overlapping. If anything was overlapping, the else event would not run.
Mistakes were made.
B
52
S
26
G
111
Posts: 1,623
Reputation: 62,667

Post » Tue Jul 26, 2016 4:08 pm

Yeah as oosyrag said
Else is more open. It means do any of this if the comparison is not true.
If sprite is overlapping background- do foo
Else- do some other foo

Inverted means the opposite of the comparison.
inverted sprite is overlapping background- do foo = sprite is not overlapping background- do foo

They are about the same, but else gives you the option to do something if a comparison is true as well, but you have to keep in mind inverted may not always work as expected.

Additionally else will not do any picking, so you would have to add extra conditions for that.
Image ImageImage
B
169
S
50
G
174
Posts: 8,331
Reputation: 110,806

Post » Tue Jul 26, 2016 4:28 pm

Alright. I understood for now. Thank you oosyrag and newt for the information :D
B
10
S
3
G
1
Posts: 12
Reputation: 1,008

Post » Thu Aug 04, 2016 2:52 pm

Else is also great to add in a lot of situations because once it finds a true statement it will skip over the else.

Example

var Color = blue

If color = blue
--set color = red
if color != blue
--set color = purple

The color would end up being purple. The first statement would change to red making the second statement true when reached. If that isn't what was intended you can add the else:

If color = blue
--set color = red
Else
--set color = purple

This would result in the color being red. The first statement was true so the Else statement was skipped.
ImageImageImage
B
40
S
23
G
11
Posts: 498
Reputation: 10,062


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests