-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSpriteClone.java
More file actions
36 lines (28 loc) · 874 Bytes
/
SpriteClone.java
File metadata and controls
36 lines (28 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package reference;
import org.openpatch.scratch.*;
import org.openpatch.scratch.extensions.recorder.*;
public class SpriteClone {
public SpriteClone() {
Stage myStage = new Stage(600, 240);
Sprite original = new Sprite("gamma", "assets/gamma_purple_badge.png");
original.setPosition(-100, 0);
myStage.add(original);
GifRecorder recorder =
new GifRecorder("examples/reference/" + this.getClass().getName() + ".gif");
recorder.start();
// Clone the sprite
Sprite clone = original.clone();
clone.setPosition(100, 0);
myStage.add(clone);
myStage.wait(1500);
// Move both sprites to show they are independent
original.move(30);
clone.move(-30);
myStage.wait(1500);
recorder.stop();
myStage.exit();
}
public static void main(String[] args) {
new SpriteClone();
}
}