-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSpriteDisableHitbox.java
More file actions
41 lines (32 loc) · 1.09 KB
/
SpriteDisableHitbox.java
File metadata and controls
41 lines (32 loc) · 1.09 KB
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
37
38
39
40
41
package reference;
import org.openpatch.scratch.*;
import org.openpatch.scratch.extensions.recorder.*;
public class SpriteDisableHitbox {
public SpriteDisableHitbox() {
Stage myStage = new Stage(600, 240);
Sprite gamma = new Sprite("gamma", "assets/gamma_purple_badge.png");
Sprite zeta = new Sprite("zeta", "assets/zeta_green_badge.png");
gamma.setPosition(-20, 0);
zeta.setPosition(20, 0);
myStage.add(gamma);
myStage.add(zeta);
GifRecorder recorder =
new GifRecorder("examples/reference/" + this.getClass().getName() + ".gif");
recorder.start();
// Check collision before disabling hitbox
gamma.say("Touching: " + gamma.isTouchingSprite(zeta));
myStage.wait(1500);
// Disable hitbox
gamma.disableHitbox();
gamma.say("Hitbox disabled");
myStage.wait(1000);
// Check collision after disabling
gamma.say("Touching: " + gamma.isTouchingSprite(zeta));
myStage.wait(1500);
recorder.stop();
myStage.exit();
}
public static void main(String[] args) {
new SpriteDisableHitbox();
}
}