For updates, you should follow me on


Using repeat loops in buttons


The loop command allows you to repeat button actions a set number of times.  Everything should work with the loop command except user inputs - which are dealt with before all other button actions.  The command and parameters are;

 

loop

 

A special loop counter variable is created ( $@ ) which you can use in your commands.

 

 

The following commands were used for a wave effect.  There are five boxes (color sources) at the bottom of the screen (Box1 ... Box5).  The boxes are side by side, filling the width of the screen.

 

 

Create a loop for the 5 boxes

loop

start=1

end=5

step=1

 

Move boxes upwards

animate

delay=[$@ * 100]

scene=_current

item=Box$@

queue=1

y=(-20)

steps=5

interval=5

 

Move boxes back down

animate

scene=_current

item=Box$@

y=(20)

steps=5

interval=5

 

 

To create the wave effect, each box has a slightly longer delay before it starts to move - using the loop couter variable $@ multiplied by 100 (millisecs).  Note that the animation queue is enabled for each object so that any animation performed on it is finished before another begins.  Also note the brackets around the change to the y position : indicating that the change is relative to its current position.

 

Since the animation queues are enabled, we can simply animate the box back to its original position - this animation will trigger when the previous animation is complete.

 

 



Prev: Setting custom values to use in the deck  
Next: Using math expressions



Privacy
© 2024 8up.uk