Scratch for Java

AnimatedSprite::setAnimationFrame()

Sets the current frame of an animation.

Examples

import org.openpatch.scratch.*;
import org.openpatch.scratch.extensions.animation.*;
 
public class AnimatedSpriteSetAnimationFrame {
  public AnimatedSpriteSetAnimationFrame() {
    Stage myStage = new Stage(600, 240);
    AnimatedSprite bee = new AnimatedSprite();
    bee.addAnimation("idle", "assets/bee_idle.png", 6, 36, 34);
    myStage.add(bee);
    bee.changeY(20);
 
    while (myStage.getTimer().forMillis(5000)) {
      bee.playAnimation("idle");
      if (myStage.isKeyPressed(KeyCode.VK_SPACE)) {
        bee.setAnimationFrame(0);
      }
    }
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new AnimatedSpriteSetAnimationFrame();
  }
}
 

View on GitHub

Syntax

Java

.setAnimationFrame(frame)

Scratch

set animation frame ()

Parameters

Name Data Type Description
frame int Frame number

Return

void

setAnimationFrame()