create-dreamer-app 1.0.8 → 1.0.9
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
|
# Disco Dreamer reference
|
|
2
2
|
|
|
3
|
-
A practical guide to building browser games with `discodreamer`. Examples use the public API in version 1.0.
|
|
3
|
+
A practical guide to building browser games with `discodreamer`. Examples use the public API in version 1.0.6 and TypeScript with JSX.
|
|
4
4
|
|
|
5
5
|
## How a game runs
|
|
6
6
|
|
|
@@ -274,9 +274,9 @@ Rectangle bounds use their top-left corner; circle bounds use their center. `pos
|
|
|
274
274
|
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
275
|
|
|
276
276
|
- `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
|
|
277
|
+
- `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
278
|
- 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.
|
|
279
|
+
- 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
280
|
- Hits alone do not separate bodies or change their velocities.
|
|
281
281
|
- 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
282
|
|
|
@@ -286,10 +286,14 @@ function PhysicsExample() {
|
|
|
286
286
|
if (otherLayer === "world") console.log("Ball contacted world body:", otherKey);
|
|
287
287
|
});
|
|
288
288
|
|
|
289
|
+
gameHit("ball", (otherKey, otherLayer) => {
|
|
290
|
+
if (otherLayer === "world") console.log("Ball overlapped world body:", otherKey);
|
|
291
|
+
});
|
|
292
|
+
|
|
289
293
|
return (
|
|
290
294
|
<Scene>
|
|
291
295
|
<RigidBody2D key="ball" x={100} y={40}
|
|
292
|
-
layer="ball" collidesWith={["world"]} restitution={0.6}>
|
|
296
|
+
layer="ball" collidesWith={["world"]} hitsWith={["world"]} restitution={0.6}>
|
|
293
297
|
<Bounds radius={16} outline style={{ fill: "hotpink" }} />
|
|
294
298
|
</RigidBody2D>
|
|
295
299
|
<RigidBody2D key="floor" y={350} mass={0}
|