create-dreamer-app 1.0.16 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-dreamer-app",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "The scaffolding application for using Disco Dreamer.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  # Disco Dreamer reference
2
2
 
3
- A practical guide to building browser games with `discodreamer`. Examples use the public API in version 1.2.1 and TypeScript with JSX.
3
+ A practical guide to building browser games with `discodreamer`. Examples use the public API in version 1.2.2 and TypeScript with JSX.
4
4
 
5
5
  ## How a game runs
6
6
 
@@ -190,8 +190,9 @@ Displays an image or a sprite-sheet animation. Supply exactly one of `src` or `a
190
190
  | --- | --- |
191
191
  | `src` | Image URL for a static sprite |
192
192
  | `animation` | Result of `gameAnimation` |
193
+ | `subregion` | Optional source rectangle `{ x, y, width, height }`; available only with `src` |
193
194
  | `x`, `y`, `z` | Position and sibling draw order; default `0` |
194
- | `width`, `height` | Display size; defaults to image dimensions or animation frame size |
195
+ | `width`, `height` | Display size; defaults to subregion dimensions, animation frame size, or full image dimensions |
195
196
  | `rotation` | Degrees around the pivot point; default `0` |
196
197
  | `pivot` | Normalized rotation point; default `{ x: 0.5, y: 0.5 }` (center) |
197
198
 
@@ -199,6 +200,14 @@ Displays an image or a sprite-sheet animation. Supply exactly one of `src` or `a
199
200
  <Sprite src="/player.png" x={100} y={80} width={64} height={64} />
200
201
  ```
201
202
 
203
+ Use `subregion` to display part of a source image. Its coordinates and dimensions are in source-image pixels, measured from the image's top-left corner. The sprite's `x` and `y` still control its position in the scene; its `width` and `height` scale the selected region when provided. Without display dimensions, this example draws at 16×16:
204
+
205
+ ```tsx
206
+ <Sprite src="/spritesheet.png"
207
+ subregion={{ x: 32, y: 0, width: 16, height: 16 }}
208
+ x={100} y={80} />
209
+ ```
210
+
202
211
  The sprite's position is its unrotated top-left corner. Images are cached by URL, and a sprite draws nothing until its image is ready. Rotation affects drawing, not physics bounds.
203
212
 
204
213
  Pivot coordinates are fractions of the displayed width and height: `{ x: 0, y: 0 }` is the top-left, and `{ x: 1, y: 1 }` is the bottom-right. The pivot applies to both static images and animation frames. Changing it changes the rotation point while preserving the image's unrotated top-left position. For example, rotate a sword near its handle:
@@ -22,6 +22,6 @@
22
22
  "vite": "^8.3.2"
23
23
  },
24
24
  "dependencies": {
25
- "discodreamer": "^1.2.1"
25
+ "discodreamer": "^1.2.2"
26
26
  }
27
27
  }