DanmakuJSON Actions

Actions are the essential element for controlling the behaviour and movement of bullets and emitters. They work very similar to functions in many programming languages.

Syntax

The general syntax for an action-call looks like this:

{action: {parameterA: valueX, parameterB: valueY}}

In most cases, you have to pass certain parameters to an action but if there are no required parameters and you don't want to pass any, you can omit the curly brackets and just write the name of the action (the destroy-action can be used this way, for example).

Time-based execution

The execution of actions happens sequentially and some actions will take effect immediately (shoot, for example) but in many cases you might want to make things happen over time (like rotating a bullet). For those cases, some actions accept a parameter which specifies how much time it will take to transition from the current state to the target state. Time-based actions are executed in parallel by default which makes it possible to change multiple properties simultaneously (speed and rotation, for example). If you explicitly want a time-based action to finish before any subsequent actions are executed, you can pass a boolean parameter (usually called wait) to achieve that. For delays which are independent of an action's duration, you can make use of the wait-action.

Actions Overview

ActionDescription
aimRotates the bullet-source so that it points to a given target
callCalls a procedure
changeSpeedChanges the speed of the bullet-source
destroyDestroys the bullet-source
repeatRepeats a list of actions for a given number of times
rotateRotates the bullet-source
setSets a variable to a given value
shiftShifts the bullet-source vertically and/or horizontally
shootShoots a bullet from the bullet-source
triggerFires a named trigger
waitPauses the behaviour of the bullet-source for a given duration

Leave a comment