rex_zigzag
Introduction
Using LOGO-like script to move or rotate sprite.
Using LOGO-like script to move or rotate sprite.
Usage
Run commands
Sample capx
Sample capx
- Set commands at "Commands" in properties table, or by "Action:Clean command queue", then "Action:Add commands", or "Action:Add command". The commands will be listed at next section.
- Run these commands in-order if "Start" is "Yes" in properties table. Or call "Action:Execution start". Remember set "Activated" to "Yes" in properties table, or set by "Action:Set activated". The "Activated" is an enable switch of this behavior.
Types of command
There are 5 kinds of command.
There are 5 kinds of command.
- Move Forward : "F 100" means move the spsrite forward 100 pixels
- Move Back : "B 100"
- Turn Left : "L 60" means rotate the spsrite left 60 degrees
- Turn Right : "R 60"
- Wait : "W 1" means do nothing, just wait 1 second.
F 100
Join commands by ";", for example
F 100;R 60
Repeat count
Commands will be executed repeatedly if "repeat count" is larger than 0 in properties table, or set by "Action:Set repeat count". Running infinity if repeat count is equal to 0.
Commands will be executed repeatedly if "repeat count" is larger than 0 in properties table, or set by "Action:Set repeat count". Running infinity if repeat count is equal to 0.
Stop running
Call "Action:Execution stop" to stop running.
Call "Action:Execution stop" to stop running.
Command queue
Add command into command queue by "Action:Add commands", or "Action:Add command".
Clean the command queue by "Action:Clean command queue".
"Condition:On command start" will be triggered when command executed start, and "Condition:On command finish" will be triggered when command executed finished.
"Condition:On command queue finish" will be triggered when all commands had been executed finished. This trigger will never be fired if it is in infinity mode, i.e. repeat count is 0.
"Condition:Is executing command" could be used to test if a specific kind of command is running.
Add command into command queue by "Action:Add commands", or "Action:Add command".
Clean the command queue by "Action:Clean command queue".
"Condition:On command start" will be triggered when command executed start, and "Condition:On command finish" will be triggered when command executed finished.
"Condition:On command queue finish" will be triggered when all commands had been executed finished. This trigger will never be fired if it is in infinity mode, i.e. repeat count is 0.
"Condition:Is executing command" could be used to test if a specific kind of command is running.
Moving behavior
The moving behavior of this behavior is similar with rex_moveTo behavior, which defined by "Max moving speed", "Moving acceleration", "Moving deceleration" in properties table, or set them by "Action:Set maximum moving speed", "Action:Set moving acceleration", "Action:Set moving deceleration".
"Condition:Compare moving speed" could be used to compare the current moving speed.
The moving behavior of this behavior is similar with rex_moveTo behavior, which defined by "Max moving speed", "Moving acceleration", "Moving deceleration" in properties table, or set them by "Action:Set maximum moving speed", "Action:Set moving acceleration", "Action:Set moving deceleration".
"Condition:Compare moving speed" could be used to compare the current moving speed.
Rotate behavior
The moving behavior of this behavior is defined by "Max rotation speed", "Rotation acceleration", "Rotation deceleration" in properties table, or set them by "Action:Set maximum rotation speed", "Action:Set rotation acceleration", "Action:Set rotation deceleration".
"Condition:Compare rotation speed" could be used to compare the current rotating speed.
The moving behavior of this behavior is defined by "Max rotation speed", "Rotation acceleration", "Rotation deceleration" in properties table, or set them by "Action:Set maximum rotation speed", "Action:Set rotation acceleration", "Action:Set rotation deceleration".
"Condition:Compare rotation speed" could be used to compare the current rotating speed.
Set
- "Max rotation speed" = 36000
- "Rotation acceleration" = 0
- "Rotation deceleration" = 0
Embed speed setting in commands string
Sample capx
Speed setting could be embedded in command string by a JSON array with
Sample capx
Speed setting could be embedded in command string by a JSON array with
[max,acc,dec]
For example,
F 100 [400,0,0]
The speed setting will change the moving behavior or rotate behavior of all remainder commands.
Rotatable
Sample capx
The instance could be rotated by rotating command of this behavior if set "Rotatable" to "Yes" in properties table, or set by "Action:Set rotatable".
Sample capx
The instance could be rotated by rotating command of this behavior if set "Rotatable" to "Yes" in properties table, or set by "Action:Set rotatable".
- In rotatable mode, start angle of commands is equal to the initial angle of this instance.
- In non-rotatable mode, start angle of commands is set by "Initial angle" in properties table.
Precise mode
Set "Precise mode" to "Yes" in properties table, or set by "Action:Set precise", to force sprite move to target.
Set "Precise mode" to "No" if user want to combine this zigzag behavior with other movement behavior like official sine behavior.
Set "Precise mode" to "Yes" in properties table, or set by "Action:Set precise", to force sprite move to target.
Set "Precise mode" to "No" if user want to combine this zigzag behavior with other movement behavior like official sine behavior.
Continued mode
Set "Continued mode" to "Yes" in properties table could running in a continued-time, i.e. the calculating of time will be more precisely.
Set "Continued mode" to "No" is good enough, usually.
Set "Continued mode" to "Yes" in properties table could running in a continued-time, i.e. the calculating of time will be more precisely.
Set "Continued mode" to "No" is good enough, usually.