Quartz composer/Origami: how to add a conditional logic

363 views Asked by At

I would like to make an different animation depending if the switch is off or on.

Let say if my switch is ON my sprite move x +10 if my switch is OFF my sprite move y +10

I don't find a correct way to apply it. Thanks

1

There are 1 answers

0
Andy Jazz On

You could use one out of three PatchTrees with a simple logic. The first one works like this: after pressing LMB, your sprite translates 0.1 along +X. After releasing LMB sprite returns to its default position (0). The same thing happens with pressing and releasing RMB (Y+0.1).

enter image description here

The second scheme uses slightly different logic: clicking LMB you translate your sprite X+0.1 and clicking RMB you translate your sprite Y+0.1. This logic can be accomplished if you use "Counter" patch (with "Reset" parameter).

Remember! your QC's default XY grid ranges from -1 to +1 for X and Y (totally 2 for each axis).

enter image description here

The third one is a switcher based on a formula of inversion: abs(a-b). b=1. I used patch named "Mathematical expression". This PatchTree is made just for one input (LMB for instance). Maybe third scheme is what you are looking for.

Logic is simple:

if a = 0  ->  abs(0-1)  ->  abs(-1) = 1

...

if a = 1  ->  abs(1-1)  ->  abs(0) = 0

enter image description here