# On / Off Button Problem :s

Get help using Construct 2

### » Sun May 13, 2012 4:29 pm

ohh i forgot to remove that, soz
B
40
S
11
G
4
Posts: 665
Reputation: 8,453

### » Sun May 13, 2012 4:35 pm

Thx you two :)

Could you perhaps explain a bit? So that it gets stuck in my head

@vtrix        grid = 0?1 :0

@newt          Sprite.var%2=0 ?100 :50

I mean.. I get it.. but I did not know the syntax
B
40
S
11
G
4
Posts: 665
Reputation: 8,453

### » Sun May 13, 2012 5:05 pm

Guide to Construct 2's event features

See the section on 'Else', and why it fixes events like you've set up.
Scirra Founder
B
408
S
242
G
92
Posts: 24,931
Reputation: 198,725

### » Sun May 13, 2012 5:27 pm

% or modulo returns the remainder from division so variable%2 would be the remainder of the variable divided by 2. Then as you know, any even number divided by 2 has a remainder of 0, since they are all divisible by 2. That also means any odd number will not be 0.

? : are conditionals. If you do a comparison, like 1=1, the system will take the question mark to mean that anything after ? is to be taken when the condition is true. Then anything after : is to be used if it was false. so 12%2=0 would give you 0 as a remainder, and be true.
B
173
S
50
G
195
Posts: 8,585
Reputation: 121,906

### » Sun May 13, 2012 6:37 pm

@Ashley Very Insightful Ty :)

@Newt Ah! :D Ty, I'm glad that we are able to use math in C2 if we choose too

B
40
S
11
G
4
Posts: 665
Reputation: 8,453

### » Sat May 24, 2014 6:06 pm

Hello got a trouble about 2 states sprite button (switch).
If I move button_1 to bot layer to make the button_2 at top the mouseclick is still affected at the button_1
if I make button_1 invisible and make button_2 visible the mouseclick does'nt work too in all ways the button_2 is not affected by any click because the button_1 is logicaly always present.
Tried destroy or move outside the layout but fail.
'mega.co.nz/#!4h9yjKKR!CddgGZVB0-eyT7mI0jOYSIIuKATLB7fLpW7dy0MRrAM'
(switch_fail.capx)
B
4
Posts: 10
Reputation: 222

Previous