@safe-engine/pixi 8.9.1 → 8.9.3

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.
@@ -1,30 +1,12 @@
1
- import { Tilemap } from '@pixi/tilemap';
2
- import { BaseComponentProps, Vec2 } from '..';
1
+ import { BaseComponentProps } from '..';
3
2
  import { ComponentX } from '../components/BaseComponent';
3
+ import { TiledMapContainer } from './TiledMapContainer';
4
4
  interface TiledMapCompProps extends BaseComponentProps<TiledMapComp> {
5
5
  mapFile: string;
6
6
  }
7
- export declare class TiledMapComp extends ComponentX<TiledMapCompProps, Tilemap> {
8
- mapData: any;
9
- getPositionAt(tx: number, ty: number): {
10
- x: number;
11
- y: number;
12
- equals(other: /*elided*/ any): boolean;
13
- add(value: import("pixi.js/lib/maths/point/Point").Point | Vec2): /*elided*/ any;
14
- addSelf(value: import("pixi.js/lib/maths/point/Point").Point | Vec2): /*elided*/ any;
15
- sub(value: import("pixi.js/lib/maths/point/Point").Point | Vec2): /*elided*/ any;
16
- mul(multiply: number): /*elided*/ any;
17
- mulSelf(multiply: number): /*elided*/ any;
18
- mag(): number;
19
- normalizeSelf(): /*elided*/ any;
20
- normalize(): /*elided*/ any;
21
- cross(other: Vec2): number;
22
- signAngle(other: Vec2): number;
23
- lengthSqr(): number;
24
- dot(other: Vec2): number;
25
- angle(other: Vec2): number;
26
- distance(other: /*elided*/ any): number;
27
- };
7
+ export declare class TiledMapComp extends ComponentX<TiledMapCompProps, TiledMapContainer> {
8
+ getLayer(layerName: string): import("./TiledMapContainer").TiledMapLayer;
9
+ getObjectGroup(layerName: string): any;
28
10
  render(): this;
29
11
  }
30
12
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"TiledMapComp.d.ts","sourceRoot":"","sources":["../../src/tiledmap/TiledMapComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAU,kBAAkB,EAAuB,IAAI,EAAE,MAAM,IAAI,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAGxD,UAAU,iBAAkB,SAAQ,kBAAkB,CAAC,YAAY,CAAC;IAClE,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,qBAAa,YAAa,SAAQ,UAAU,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACtE,OAAO,EAAE,GAAG,CAAA;IAEZ,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;IAKpC,MAAM;CASP"}
1
+ {"version":3,"file":"TiledMapComp.d.ts","sourceRoot":"","sources":["../../src/tiledmap/TiledMapComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,IAAI,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,UAAU,iBAAkB,SAAQ,kBAAkB,CAAC,YAAY,CAAC;IAClE,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,qBAAa,YAAa,SAAQ,UAAU,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAChF,QAAQ,CAAC,SAAS,EAAE,MAAM;IAG1B,cAAc,CAAC,SAAS,EAAE,MAAM;IAIhC,MAAM;CAQP"}
@@ -1,13 +1,14 @@
1
- import { Assets, GameWorld, NodeComp, Vec2 } from '..';
1
+ import { GameWorld, NodeComp } from '..';
2
2
  import { ComponentX } from '../components/BaseComponent';
3
- import { loadIsometricMap, tileToPixel } from './tield';
3
+ import { loadIsometricMap } from './tield';
4
4
  export class TiledMapComp extends ComponentX {
5
- getPositionAt(tx, ty) {
6
- const pos = tileToPixel(this.mapData, tx + 1, ty);
7
- return Vec2(pos);
5
+ getLayer(layerName) {
6
+ return this.node.instance.getLayer(layerName);
7
+ }
8
+ getObjectGroup(layerName) {
9
+ return this.node.instance.getObjectGroup(layerName);
8
10
  }
9
11
  render() {
10
- this.mapData = Assets.get(this.props.mapFile);
11
12
  const tiledMap = loadIsometricMap(this.props.mapFile);
12
13
  const world = GameWorld.Instance;
13
14
  const entity = world.entities.create();
@@ -0,0 +1,32 @@
1
+ import { Container } from 'pixi.js';
2
+ import { Vec2 } from '../core';
3
+ export declare class TiledMapContainer extends Container {
4
+ layers: Map<string, TiledMapLayer>;
5
+ objectGroups: Map<string, any>;
6
+ getLayer(layerName: string): TiledMapLayer;
7
+ getObjectGroup(layerName: string): any;
8
+ }
9
+ export declare class TiledMapLayer extends Container {
10
+ mapData: any;
11
+ getPositionAt(tx: number, ty: number): {
12
+ x: number;
13
+ y: number;
14
+ equals(other: /*elided*/ any): boolean;
15
+ add(value: import("pixi.js").Point | Vec2): /*elided*/ any;
16
+ addSelf(value: import("pixi.js").Point | Vec2): /*elided*/ any;
17
+ sub(value: import("pixi.js").Point | Vec2): /*elided*/ any;
18
+ mul(multiply: number): /*elided*/ any;
19
+ mulSelf(multiply: number): /*elided*/ any;
20
+ mag(): number;
21
+ normalizeSelf(): /*elided*/ any;
22
+ normalize(): /*elided*/ any;
23
+ cross(other: Vec2): number;
24
+ signAngle(other: Vec2): number;
25
+ lengthSqr(): number;
26
+ dot(other: Vec2): number;
27
+ angle(other: Vec2): number;
28
+ distance(other: /*elided*/ any): number;
29
+ };
30
+ getTileAt(tx: number, ty: number): import("pixi.js").ContainerChild;
31
+ }
32
+ //# sourceMappingURL=TiledMapContainer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TiledMapContainer.d.ts","sourceRoot":"","sources":["../../src/tiledmap/TiledMapContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAG9B,qBAAa,iBAAkB,SAAQ,SAAS;IAC9C,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAY;IAC9C,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAY;IAE1C,QAAQ,CAAC,SAAS,EAAE,MAAM;IAI1B,cAAc,CAAC,SAAS,EAAE,MAAM;CAGjC;AAED,qBAAa,aAAc,SAAQ,SAAS;IAC1C,OAAO,EAAE,GAAG,CAAA;IACZ,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;IAKpC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CAIjC"}
@@ -0,0 +1,26 @@
1
+ import { Container } from 'pixi.js';
2
+ import { Vec2 } from '../core';
3
+ import { tileToPixel } from './tield';
4
+ export class TiledMapContainer extends Container {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.layers = new Map();
8
+ this.objectGroups = new Map();
9
+ }
10
+ getLayer(layerName) {
11
+ return this.layers.get(layerName);
12
+ }
13
+ getObjectGroup(layerName) {
14
+ return this.objectGroups.get(layerName);
15
+ }
16
+ }
17
+ export class TiledMapLayer extends Container {
18
+ getPositionAt(tx, ty) {
19
+ const pos = tileToPixel(this.mapData, tx + 1, ty);
20
+ return Vec2(pos);
21
+ }
22
+ getTileAt(tx, ty) {
23
+ const idx = 0 | (tx + ty * this.mapData.width);
24
+ return this.children[idx];
25
+ }
26
+ }
@@ -1,7 +1,7 @@
1
- import { Tilemap } from '@pixi/tilemap';
1
+ import { TiledMapContainer } from './TiledMapContainer';
2
2
  export declare function tileToPixel(map: any, tx: any, ty: any): {
3
3
  x: number;
4
4
  y: number;
5
5
  };
6
- export declare function loadIsometricMap(mapUrl: string): Tilemap;
6
+ export declare function loadIsometricMap(mapUrl: string): TiledMapContainer;
7
7
  //# sourceMappingURL=tield.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tield.d.ts","sourceRoot":"","sources":["../../src/tiledmap/tield.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,wBAAgB,WAAW,CAAC,GAAG,KAAA,EAAE,EAAE,KAAA,EAAE,EAAE,KAAA;;;EA0BtC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,WAiC9C"}
1
+ {"version":3,"file":"tield.d.ts","sourceRoot":"","sources":["../../src/tiledmap/tield.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,qBAAqB,CAAA;AAEtE,wBAAgB,WAAW,CAAC,GAAG,KAAA,EAAE,EAAE,KAAA,EAAE,EAAE,KAAA;;;EA0BtC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,qBAyC9C"}
@@ -1,5 +1,5 @@
1
- import { Tilemap } from '@pixi/tilemap';
2
- import { Assets, Rectangle, Texture } from 'pixi.js';
1
+ import { Assets, Rectangle, Sprite, Texture } from 'pixi.js';
2
+ import { TiledMapContainer, TiledMapLayer } from './TiledMapContainer';
3
3
  export function tileToPixel(map, tx, ty) {
4
4
  const tw = map.tilewidth;
5
5
  const th = map.tileheight;
@@ -35,10 +35,15 @@ export function loadIsometricMap(mapUrl) {
35
35
  const tileH = tileset.tileheight;
36
36
  const cols = tileset.columns;
37
37
  const firstGid = tileset.firstgid;
38
- const tilemap = new Tilemap(baseTexture);
38
+ const tilemap = new TiledMapContainer();
39
+ // tilemap.mapData = mapData
39
40
  for (const layer of mapData.layers) {
40
41
  if (layer.type !== 'tilelayer')
41
42
  continue;
43
+ const tileLayer = new TiledMapLayer();
44
+ tileLayer.mapData = mapData;
45
+ tilemap.layers.set(layer.name, tileLayer);
46
+ tilemap.addChild(tileLayer);
42
47
  const data = layer.data;
43
48
  for (let i = 0; i < data.length; i++) {
44
49
  const gid = data[i];
@@ -51,7 +56,10 @@ export function loadIsometricMap(mapUrl) {
51
56
  const ty = Math.floor(i / mapData.width);
52
57
  const { x, y } = tileToPixel(mapData, tx, ty);
53
58
  const texture = new Texture({ source: baseTexture, frame: new Rectangle(frameX, frameY, tileW, tileH) });
54
- tilemap.tile(texture, x, y);
59
+ const sprite = new Sprite(texture);
60
+ sprite.x = x;
61
+ sprite.y = y;
62
+ tileLayer.addChild(sprite);
55
63
  }
56
64
  }
57
65
  return tilemap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@safe-engine/pixi",
3
- "version": "8.9.1",
3
+ "version": "8.9.3",
4
4
  "description": "safex pixi plugin",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "@pixi/ui": "^2.2.7",
23
23
  "box2d-wasm": "^7.0.0",
24
24
  "entityx-ts": "^2.3.1",
25
- "pixi-action-ease": "^3.3.1",
25
+ "pixi-action-ease": "^3.3.2",
26
26
  "pixi-tagged-text-plus": "0.0.1-next.2",
27
27
  "pixi.js": "8.12.0",
28
28
  "planck": "^1.4.2"