AnimatedSprite::setAnimationInterval()
Sets the animation interval. The animation interval determines how fast an animation is played. Lower numbers mean faster playback.
Examples

import org.openpatch.scratch.KeyCode;
import org.openpatch.scratch.extensions.animation.AnimatedSprite;
public class MySprite extends AnimatedSprite {
public MySprite() {
this.addAnimation("idle", "assets/bee_idle.png", 6, 36, 34);
}
public void run() {
this.playAnimation("idle");
if (this.isKeyPressed(KeyCode.VK_S)) {
this.setAnimationInterval(60);
} else if (this.isKeyPressed(KeyCode.VK_W)) {
this.setAnimationInterval(10);
}
}
}
import org.openpatch.scratch.Stage;
public class MyStage extends Stage {
public MyStage() {
this.add(new MySprite());
}
}
import org.openpatch.scratch.Stage;
import org.openpatch.scratch.Window;
public class MyWindow extends Window {
public MyWindow() {
Stage myStage = new MyStage();
this.setStage(myStage);
// Wait for 5 seconds
while (myStage.getTimer().forMillis(5000))
;
this.exit();
}
public static void main(String[] args) {
new MyWindow();
}
}
Syntax
Java
.setAnimationInterval(interval)
Scratch
set animation interval ()
Parameters
Name | Data Type | Description |
---|---|---|
interval | int | Animation interval. Lower numbers mean faster playback. |
Return
void