if then ELSE (or case selection) functionality

Mar 05, 2015

Hi All,

I've got two Kayak images (left stroke and right stroke).  I've set up the two images as different states.  Each time the user presses the UP key, I want triggers to:

  1. Identify the current state of the object.
  2. Alternate to the other state.

Seems like a simple enough problem.  Not so easy to program with triggers; as it runs all the triggers and returns it to first state.

Can anybody suggest a work-around?

Kind Regards,

Simon Wood

5 Replies
Midi Prefix

My workaround to the terrible situation of top down triggers, is to use layers.

I have one layer with the first clickable object on it, which has a trigger that hides itself, and shows the second layer, which has the next clickable object on it, which does the same. So you click one, it hides, and shows the other, then you click that, it hides, and shows the other, and so on.

However, I use this workaround with clicks, not key presses, so I don't think it would work here. It is a pretty huge shame there is no break; command in the triggers to stop the top down madness that it enforces.

Tony Jones

I think this method should work, using just three triggers with your two states (left and right):

  1. Create a True/False variable that will act as the switch controller e.g. StrokeLeft, and set its initial variable as true
  2. Create your first slide trigger, where you toggle StrokeLeft when UP is pressed (Operator = NOT Assignment), changing its from True to False or vice versa.
  3. Create the second slide trigger, where the state of your kayak is changed to 'right' when UP is pressed, with the added condition of 'StrokeLeft = False'
  4. Create the final slide trigger, where the state of your kayak is changed to 'left' when UP is pressed, with the added condition of 'StrokeLeft = True'

The second and third points may sound a bit counter-intuitive (changing state to Left if StrokeLeft is True), but they're done that way to work with Storyline's logic (or lack of!).

Hope this helps - it worked for me.

Alexandros Anoyatis

You can use a Toggle trigger and a T/F variable for that.

Create a T/F variable (any initial value) and a trigger in the form of : Adjust variable 'x' to NOT Assignment when user presses the Up Key.

Then two listener triggers:
- Change state of 'Image' to 'Right' when variable 'x' changes on condition variable 'x'==True
- Change state of 'Image' to 'Left' when variable 'x' changes on condition variable 'x'==False

That should do it.

Hope it helps,
Alex

This discussion is closed. You can start a new discussion or contact Articulate Support.