@ignifx/2d 0.17.0 → 0.19.0
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/dist/index.d.ts +84 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +148 -15
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/skills/2d/SKILL.md +37 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ignifx/2d",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "ignifx 2D toolkit: Camera2D, sprites, sprite animation, atlases, tilemaps, sorting layers, pixel-perfect, parallax.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ignifx",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"typedoc-plugin-markdown": "^4.13.0",
|
|
44
44
|
"typescript-native": "npm:typescript@7.0.2",
|
|
45
45
|
"vitest": "^5.0.0",
|
|
46
|
-
"@ignifx/core": "0.
|
|
46
|
+
"@ignifx/core": "0.19.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@babylonjs/lite": "1.34.0",
|
|
50
|
-
"@ignifx/core": "0.
|
|
50
|
+
"@ignifx/core": "0.19.0"
|
|
51
51
|
},
|
|
52
52
|
"ignifx": {
|
|
53
53
|
"extension": true,
|
package/skills/2d/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: 2d
|
|
|
3
3
|
description: Builds 2D games in ignifx with @ignifx/2d: Camera2D, SpriteRenderer, SpriteAnimator, texture atlases, Tilemap rendering and import, sorting layers and Y-sort, pixel-perfect cameras, parallax layers, sprite batches, and 2D picking. Use when adding or editing sprites, sprite animation, tilemaps, atlases, sorting layers, sprite batches, or a 2D camera in an ignifx project, or when the user mentions @ignifx/2d, Camera2D, SpriteRenderer, SpriteBatch, or Tilemap.
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
metadata:
|
|
6
|
-
ignifx-version: "0.
|
|
6
|
+
ignifx-version: "0.19.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# @ignifx/2d
|
|
@@ -21,7 +21,7 @@ parse, `SpriteAnimator` advances on the stepped clock. Only the pixels need a GP
|
|
|
21
21
|
|
|
22
22
|
## Environment
|
|
23
23
|
|
|
24
|
-
- Engine: ignifx `0.
|
|
24
|
+
- Engine: ignifx `0.19.0`; this package targets `@ignifx/core` `>=0.0.0 <1.0.0`.
|
|
25
25
|
- WebGPU only, browser and Electron. Babylon Lite `1.34.0` is a peer dependency.
|
|
26
26
|
- Register it like any extension; nothing happens at import time.
|
|
27
27
|
|
|
@@ -243,6 +243,36 @@ ignifx import tilemap assets/maps/cave.tmj --pixels-per-unit 16
|
|
|
243
243
|
ignifx import tilemap assets/maps/world.ldtk assets/levels --pixels-per-unit 16
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
+
### A map built in code
|
|
247
|
+
|
|
248
|
+
`createTilemapAsset(app, input, { address })` publishes a map generated at run time, in the same
|
|
249
|
+
shape a `.tilemap.json` holds, and checks it the way the loader does (a bad grid throws `IGX-1105`).
|
|
250
|
+
`address` is what the tilesets' `atlas` references resolve against; without it they are read as
|
|
251
|
+
project-root addresses. The handle is a `memory:` asset, so a scene saved with it writes `null`.
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
import { createTilemapAsset, Tilemap, TilemapRenderer } from "ignifx";
|
|
255
|
+
import type { App, AssetHandle, SpriteAtlasAsset } from "ignifx";
|
|
256
|
+
|
|
257
|
+
/** A one-row strip of alternating tiles, for a generated level. */
|
|
258
|
+
export function buildStrip(app: App, atlas: AssetHandle<SpriteAtlasAsset>, width: number): void {
|
|
259
|
+
const tiles: number[] = [];
|
|
260
|
+
for (let x = 0; x < width; x += 1) {
|
|
261
|
+
tiles.push(1 + (x % 2));
|
|
262
|
+
}
|
|
263
|
+
const map = createTilemapAsset(app, {
|
|
264
|
+
tileWidth: 16,
|
|
265
|
+
width,
|
|
266
|
+
height: 1,
|
|
267
|
+
tilesets: [{ name: "terrain", atlas: "2d/terrain.atlas.json", firstId: 1, tiles: [] }],
|
|
268
|
+
layers: [{ name: "Ground", tiles, collision: true }],
|
|
269
|
+
});
|
|
270
|
+
const level = app.world.createEntity("Level");
|
|
271
|
+
level.addComponent(Tilemap).map = map;
|
|
272
|
+
level.addComponent(TilemapRenderer).atlas = atlas;
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
246
276
|
### Picking a sprite under the pointer
|
|
247
277
|
|
|
248
278
|
```ts run
|
|
@@ -336,8 +366,11 @@ Generated reference: `skills/ignifx/references/formats/`.
|
|
|
336
366
|
for pixel art.
|
|
337
367
|
- **Cell `(0, 0)` is the bottom-left of a tilemap**, because the world is +Y up — but the file stores
|
|
338
368
|
its rows **top first**, like every editor. `Tilemap` flips on load; `getTile` speaks cells.
|
|
339
|
-
-
|
|
340
|
-
Lite draws by insertion order. Turn Y-sort on, or use separate sorting
|
|
369
|
+
- **A `SpriteRenderer`'s `orderInLayer` only reorders inside a Y-sorted layer.** Without `ySort`
|
|
370
|
+
for that sorting layer, Lite draws by insertion order. Turn Y-sort on, or use separate sorting
|
|
371
|
+
layers. A tilemap layer's `orderInLayer` always applies. Without Y-sort, tiles draw by
|
|
372
|
+
`orderInLayer`, then by the layer's place in the file, and behind the sorting layer's sprites
|
|
373
|
+
when the orders tie. With Y-sort, it is the tiles' Y-sort bias, as for a sprite.
|
|
341
374
|
- **A frame's pivot moves the sprite, not the layer.** Lite has one pivot per layer, so ignifx
|
|
342
375
|
offsets each sprite instead. A `[0.5, 1]` pivot puts the entity's origin at the sprite's feet.
|
|
343
376
|
- **`pixelPerfect` ignores `orthographicSize`** and scales `referenceResolution` by a whole number
|