Skip to content

Commit 6303edf

Browse files
author
Mike Barkmin
committed
Add more debug information
1 parent a8e3699 commit 6303edf

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ void draw() {
3131
}
3232
```
3333

34+
With `ScratchStage.init(this, true)` you can enable the debug mode. It will display the mouse cursor position and all hitboxes.
35+
3436
#### Looks
3537

3638
| Scratch | Processing |

src/eu/barkmin/processing/scratch/ScratchImage.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ public void draw(float size, float degrees, float x, float y) {
163163
parent.tint(this.tint.getRed(), this.tint.getGreen(), this.tint.getBlue(), this.transparency);
164164
parent.image(this.image, 0, 0);
165165
parent.noTint();
166+
if(ScratchStage.getInstance().isDebug()) {
167+
parent.fill(ScratchStage.DEBUG_COLOR[0], ScratchStage.DEBUG_COLOR[1], ScratchStage.DEBUG_COLOR[1]);
168+
parent.textAlign(parent.CENTER);
169+
parent.text("Rotation: " + degrees, 0, - newHeight/2.0f - 10);
170+
parent.text("(" + x + ", " + y + ")", 0, 0);
171+
}
166172
parent.popMatrix();
167173

168174
}

src/eu/barkmin/processing/scratch/ScratchSprite.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,10 @@ public void setHitbox(int[] xPoints, int[] yPoints) {
625625
}
626626

627627
public ScratchHitbox getHitbox() {
628-
ScratchImage currentCostume = this.costumes.get(this.getCurrentCostumeIndex());
628+
ScratchImage currentCostume = null;
629+
if (this.costumes.size() > this.getCurrentCostumeIndex()) {
630+
currentCostume = this.costumes.get(this.getCurrentCostumeIndex());
631+
}
629632
float costumeWidth = currentCostume != null ? currentCostume.getImage().width : this.pen.getSize();
630633
float costumeHeight = currentCostume != null ? currentCostume.getImage().height : this.pen.getSize();
631634
float spriteWidth = this.show ? costumeWidth : this.pen.getSize();

0 commit comments

Comments
 (0)