create-dreamer-app 1.0.8 → 1.0.10

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.8",
3
+ "version": "1.0.10",
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.0.2 and TypeScript with JSX.
3
+ A practical guide to building browser games with `discodreamer`. Examples use the public API in version 1.0.7 and TypeScript with JSX.
4
4
 
5
5
  ## How a game runs
6
6
 
@@ -147,12 +147,13 @@ The sprite's position is its unrotated top-left corner. Images are cached by URL
147
147
 
148
148
  ### `Text`
149
149
 
150
- Draws white, left-aligned, top-aligned text. Uses `sans-serif` unless a font family is supplied.
150
+ Draws left-aligned, top-aligned text in the supplied `color`, or white by default. Uses `sans-serif` unless a font family is supplied.
151
151
 
152
152
  | Prop | Default | Purpose |
153
153
  | --- | --- | --- |
154
154
  | `value` | Required | Text string to draw |
155
155
  | `x`, `y`, `z` | `0` | Position and sibling draw order |
156
+ | `color` | `"white"` | Text fill color as a canvas color string, such as `"red"` or `"#ff00ff"` |
156
157
  | `fontSize` | `25` | Font size in pixels |
157
158
  | `font` | `""` (renders as `sans-serif`) | Font family name, such as a name registered with `addCustomFont` |
158
159
  | `width` | `Infinity` | Maximum canvas text draw width |
@@ -161,7 +162,7 @@ A finite `width` limits the canvas text draw width; it does not create wrapping
161
162
 
162
163
  ```tsx
163
164
  <Text x={16} y={16} value="Score: 10" fontSize={24} />
164
- <Text x={16} y={48} value="Custom font" font="PixelFont" fontSize={32} />
165
+ <Text x={16} y={48} value="Custom font" font="PixelFont" fontSize={32} color="#ff00ff" />
165
166
  ```
166
167
 
167
168
  ## Custom fonts
@@ -274,9 +275,9 @@ Rectangle bounds use their top-left corner; circle bounds use their center. `pos
274
275
  Call these each frame with the body's public `key`. The handler receives the other body's public key once per reported body pair per frame.
275
276
 
276
277
  - `gameCollision` calls `handler(otherKey: string, otherLayer: string)`, passing the other body's public key and layer. The layer is always defined for a physical collision.
277
- - `gameHit` calls `handler(otherKey: string)`, passing only the other body's public key.
278
+ - `gameHit` calls `handler(otherKey: string, otherLayer: string)`, passing the other body's public key and layer. The other body's layer is always defined for a hit.
278
279
  - Physical collisions require both bodies to include each other's `layer` in `collidesWith`.
279
- - Hits are directional: only the observing body's `hitsWith` needs to include the other body's layer.
280
+ - Hits are directional: only the observing body's `hitsWith` needs to include the other body's layer. The observing body does not need its own layer.
280
281
  - Hits alone do not separate bodies or change their velocities.
281
282
  - Hooks read the previous frame's contact results because the current collision pass happens after tree construction. Contacts are reported repeatedly while detected; these are not enter/exit events.
282
283
 
@@ -286,10 +287,14 @@ function PhysicsExample() {
286
287
  if (otherLayer === "world") console.log("Ball contacted world body:", otherKey);
287
288
  });
288
289
 
290
+ gameHit("ball", (otherKey, otherLayer) => {
291
+ if (otherLayer === "world") console.log("Ball overlapped world body:", otherKey);
292
+ });
293
+
289
294
  return (
290
295
  <Scene>
291
296
  <RigidBody2D key="ball" x={100} y={40}
292
- layer="ball" collidesWith={["world"]} restitution={0.6}>
297
+ layer="ball" collidesWith={["world"]} hitsWith={["world"]} restitution={0.6}>
293
298
  <Bounds radius={16} outline style={{ fill: "hotpink" }} />
294
299
  </RigidBody2D>
295
300
  <RigidBody2D key="floor" y={350} mass={0}
@@ -22,6 +22,6 @@
22
22
  "vite": "^8.3.2"
23
23
  },
24
24
  "dependencies": {
25
- "discodreamer": "^1.0.5"
25
+ "discodreamer": "^1.0.7"
26
26
  }
27
27
  }