Scratch for Java

AnimatedSprite::addAnimation()

Adds an animation to the sprite.

sprite.addAnimation("walk", i -> "walk_" + i + ".png", 3);

Examples

View on GitHub

Syntax

Java

.addAnimation(name, pattern, frames)
.addAnimation(name, builder, frame)
.addAnimation(name, path, frames, width, height)
.addAnimation(name, path, frames, width, height, row)
.addAnimation(name, path, frames, width, height, column, useColumns)

Parameters

Name Data Type Description
name String the name of the animation
pattern String the pattern (@see String#format) of the file names. The frame starts from 1.
frames int the number of frames in the animation
builder Function<Integer, String> a function that builds the file names for the animation frames
frame int the number of frames in the animation. The frame starts from 1.
path String the path to the animation frames
width int the width of each frame
height int the height of each frame
row int the row of the animation frames
column int the column of the animation frames
useColumns boolean whether to use columns or rows

Return

void

addAnimation()

Create Shareable URL

Select Sections