Skip to main content

setTempAnimation

MahiruAbout 2 min

setTempAnimation

Sets a temporary animation.

Statement Content

Unlike setAnimation, which reads animation files, setTempAnimation allows users to define multi-segment animations directly in code. See Animation Reference for details.
The statement content format is the one-line form of an animation file: [{},{},{}]. The one-line form of the new animation format also works: {"keyframes":[{},{}]}.

Info

If you want to reuse an animation, use setAnimation.
If you only want to set a single-segment animation, use setTransform.

changeFigure:1/open_eyes.png -id=aaa;
; Flashbang animation
setTempAnimation:[{"duration":0},{"brightness":2,"contrast":0,"duration":200,"ease":"circIn"},{"brightness":1,"contrast":1,"duration":200},{"brightness":2,"contrast":0,"duration":200,"ease":"circIn"},{"brightness":1,"contrast":1,"duration":2500}] -target=aaa;

Parameters

target

  • String

The target of an animation.

Available targets:

  • fig-center: center figure
  • fig-left: left figure
  • fig-right: right figure
  • fig-left13, fig-right13, fig-left14, fig-right14: the figure at the corresponding position
  • The id of a free figure
  • bg-main: background
  • stage-main: stage
changeFigure:1/open_eyes.png -id=aaa;
setTempAnimation:[{"duration":0},{"brightness":2,"contrast":0,"duration":200,"ease":"circIn"},{"brightness":1,"contrast":1,"duration":200},{"brightness":2,"contrast":0,"duration":200,"ease":"circIn"},{"brightness":1,"contrast":1,"duration":2500}] -target=aaa;

transformFrom

  • String
  • Available values: current, default
  • Default value: current

Specifies where the animation's transform starts from, i.e. how transform and effect properties not written in the animation are handled.

  • current: Starts from the object's current transform. The animation only modifies the properties it writes. Other properties keep their current values, and properties being modified by other parallel animations on the same object are not overwritten.
  • default: Starts from the default transform. Properties not written in the animation are reset to their default values.

When this argument is set, the legacy writeDefault argument is ignored.

changeFigure:1/open_eyes.png -id=aaa;
setTempAnimation:[{"duration":0},{"brightness":2,"contrast":0,"duration":200,"ease":"circIn"},{"brightness":1,"contrast":1,"duration":200},{"brightness":2,"contrast":0,"duration":200,"ease":"circIn"},{"brightness":1,"contrast":1,"duration":2500}] -target=aaa -transformFrom=default;

writeDefault

  • Boolean

Note

This argument is deprecated. Use transformFrom instead: -writeDefault is equivalent to -transformFrom=default. When transformFrom is set, this argument is ignored.

When the value is true, all unassigned transform and effect properties are written with their default values.
When the value is false, unassigned properties inherit the existing values.

changeFigure:1/open_eyes.png -id=aaa;
setTempAnimation:[{"duration":0},{"brightness":2,"contrast":0,"duration":200,"ease":"circIn"},{"brightness":1,"contrast":1,"duration":200},{"brightness":2,"contrast":0,"duration":200,"ease":"circIn"},{"brightness":1,"contrast":1,"duration":2500}] -target=aaa -writeDefault;

keep

  • Boolean

Converts the animation into a cross-statement animation. The current animation keeps playing while subsequent statements run, until it ends or is interrupted by another setTransform, setAnimation, or setTempAnimation with the same target.
It is usually used together with the next parameter.

changeFigure:1/open_eyes.png -id=aaa;
setTempAnimation:[{"duration":0},{"scale":{"x":2,"y":2},"duration":10000}] -target=aaa -keep -next;
CharacterA:First line;
CharacterA:Second line;
CharacterA:Third line;
; This interrupts aaa's cross-statement animation and plays a new animation
setTempAnimation:[{"duration":0},{"scale":{"x":1,"y":1},"duration":10000}] -target=aaa -keep -next;

parallel

  • Boolean

Plays alongside other animations already running on the same target.

By default, a new setTransform setAnimation setTempAnimation on the same target interrupts the animation currently playing on it. With -parallel, the new animation does not interrupt existing ones, and they play at the same time. A later animation without -parallel still interrupts all running animations on the target, including parallel ones.

Parallel animations should modify different properties. If several parallel animations modify the same property, the result is unpredictable. With -parallel, the animation only modifies the properties it writes.

changeFigure:1/open_eyes.png -id=aaa;
; Move and change brightness at the same time
setTransform:{"position":{"x":-500}} -target=aaa -duration=1000 -next;
setTempAnimation:[{"duration":0},{"brightness":0.5,"duration":1000}] -target=aaa -parallel;

relative

  • Boolean

Whether the animation is relative. See Relative Animation.

When the content is a keyframe array, adding -relative or -inherit makes the animation follow the rules of the new format, while keyframes still use duration. When the content is a new-format object, this argument overrides its relative field.

changeFigure:1/open_eyes.png -id=aaa;
; Move 200 to the right from the current position
setTempAnimation:[{"duration":0},{"position":{"x":200},"duration":500}] -target=aaa -relative;

inherit

  • Boolean

Whether keyframe inheritance is enabled. See Keyframe Inheritance. Like -relative, adding this argument makes a keyframe array follow the rules of the new format.

changeFigure:1/open_eyes.png -id=aaa;
setTempAnimation:[{"duration":0},{"position":{"x":200},"duration":500},{"alpha":0.5,"duration":500}] -target=aaa -relative -inherit;