Skip to content

Commit 56a0585

Browse files
authored
Merge pull request #25 from openpatch/changeset
Release v4.28.2
2 parents a9a1be9 + efc04c1 commit 56a0585

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

‎.changeset/make-sprite-testable.md‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎CHANGELOG.md‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
---
22
name: Changelog
3-
index: 59
3+
index: 60
44
lang: en
55
---
66

7+
## 4.28.2
8+
9+
10+
11+
`Sprite` (and therefore `AnimatedSprite`) can now be constructed and used without a running `Window`/`Applet`, which previously crashed the whole JVM via `System.exit()`.
12+
13+
- **Root cause**: `Sprite()`'s constructor builds a `Text`, whose constructor eagerly loaded the library's default font through the Processing asset pipeline. With no live `Applet`, that load failed and the asset-error reporter called `System.exit()`. `Font` now defers loading the underlying font file until it is actually needed (the first `getFont()` call during rendering), instead of doing it synchronously in its constructor. This matches how the library already preloads assets in the background once a `Window` is running (`Applet.loadAssets()`), and doesn't change behavior for normal (non-test) usage.
14+
- **`Sprite.ifOnEdgeBounce()`** used to throw a `NullPointerException` if called before the sprite was added to a stage (it read stage border fields unconditionally). It's now a no-op in that case, consistent with how other stage-dependent drawing code already guards on `stage == null`.
15+
16+
Together these make it possible to unit test a `Sprite` subclass's movement/geometry logic (and now `run()`, as long as it doesn't touch other stage-dependent queries) without spinning up a real window - which is exactly what the newly added `SpriteTest`, `AnimatedSpriteTest`, and `FontTest` do.
17+
18+
Note: sprites with costumes still require a live `Applet` to construct, since loading actual image pixel data (width/height) is inherent to adding a costume - this only unblocks bare `Sprite`/`AnimatedSprite` construction and costume-free logic.
19+
20+
721
## 4.28.1
822

923

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>org.openpatch</groupId>
77
<artifactId>scratch</artifactId>
8-
<version>4.28.1</version>
8+
<version>4.28.2</version>
99
<packaging>jar</packaging>
1010

1111
<name>Scratch for Java</name>

0 commit comments

Comments
 (0)