@safe-engine/pixi 8.8.5 → 8.8.7
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/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsComponent.js +1 -0
- package/dist/box2d-wasm/PhysicsSystem.js +1 -1
- package/dist/box2d-wasm/index.d.ts +2 -2
- package/dist/box2d-wasm/index.d.ts.map +1 -1
- package/dist/box2d-wasm/index.js +4 -3
- package/dist/tiledmap/TiledMapComp.d.ts +31 -0
- package/dist/tiledmap/TiledMapComp.d.ts.map +1 -0
- package/dist/tiledmap/TiledMapComp.js +22 -0
- package/dist/tiledmap/index.d.ts +2 -0
- package/dist/tiledmap/index.d.ts.map +1 -0
- package/dist/tiledmap/index.js +5 -0
- package/dist/tiledmap/tield.d.ts +3 -0
- package/dist/tiledmap/tield.d.ts.map +1 -0
- package/dist/tiledmap/tield.js +36 -0
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhysicsComponent.d.ts","sourceRoot":"","sources":["../../src/box2d-wasm/PhysicsComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAG/C,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAChB,OAAO,CAAC,EAAE,KAAK,CAAA;IACf,WAAW,CAAC,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,cAAc,CAAC,EAAE,CAAC,KAAK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A2B,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;CAAI"}
|
|
@@ -61,7 +61,7 @@ export class PhysicsSystem {
|
|
|
61
61
|
const { b2BodyDef, b2FixtureDef, b2PolygonShape, b2CircleShape, b2Vec2, b2World, pointsToVec2Array, getPointer } = box2D;
|
|
62
62
|
const gravity = new b2Vec2(0, 10);
|
|
63
63
|
this.world = new b2World(gravity);
|
|
64
|
-
console.log('configure world', event_manager.world.app)
|
|
64
|
+
// console.log('configure world', (event_manager.world as GameWorld).app)
|
|
65
65
|
// event_manager.world.physicsManager = this
|
|
66
66
|
const graphics = new Graphics();
|
|
67
67
|
this.graphics = graphics;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Vec2 } from '..';
|
|
2
2
|
export * from './PhysicsComponent';
|
|
3
3
|
export * from './PhysicsSprite';
|
|
4
4
|
export * from './PhysicsSystem';
|
|
5
|
-
export declare function setupPhysics(
|
|
5
|
+
export declare function setupPhysics(colliderMatrix: any, isDebugDraw?: boolean, gravity?: Vec2): void;
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/box2d-wasm/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/box2d-wasm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,IAAI,EAAE,MAAM,IAAI,CAAA;AAGpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAE/B,wBAAgB,YAAY,CAAC,cAAc,KAAA,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,IAAI,QAUjF"}
|
package/dist/box2d-wasm/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { GameWorld } from '..';
|
|
2
|
-
import { PhysicsSystem } from './PhysicsSystem';
|
|
2
|
+
import { PhysicsSystem, setColliderMatrix } from './PhysicsSystem';
|
|
3
3
|
export * from './PhysicsComponent';
|
|
4
4
|
export * from './PhysicsSprite';
|
|
5
5
|
export * from './PhysicsSystem';
|
|
6
|
-
export function setupPhysics(
|
|
6
|
+
export function setupPhysics(colliderMatrix, isDebugDraw, gravity) {
|
|
7
7
|
// console.log('app world', world.app)
|
|
8
|
-
const physicsSystem =
|
|
8
|
+
const physicsSystem = GameWorld.Instance.addSystemAndUpdate(PhysicsSystem);
|
|
9
9
|
if (isDebugDraw) {
|
|
10
10
|
physicsSystem.addDebug();
|
|
11
11
|
}
|
|
12
12
|
if (gravity) {
|
|
13
13
|
physicsSystem.gravity = gravity;
|
|
14
14
|
}
|
|
15
|
+
setColliderMatrix(colliderMatrix);
|
|
15
16
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Tilemap } from '@pixi/tilemap';
|
|
2
|
+
import { BaseComponentProps, Vec2 } from '..';
|
|
3
|
+
import { ComponentX } from '../components/BaseComponent';
|
|
4
|
+
interface TiledMapCompProps extends BaseComponentProps<TiledMapComp> {
|
|
5
|
+
mapFile: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class TiledMapComp extends ComponentX<TiledMapCompProps, Tilemap> {
|
|
8
|
+
mapData: any;
|
|
9
|
+
getPositionAt(x: 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
|
+
};
|
|
28
|
+
render(): this;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=TiledMapComp.d.ts.map
|
|
@@ -0,0 +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;IACZ,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;IASnC,MAAM;CASP"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Assets, GameWorld, NodeComp, Vec2 } from '..';
|
|
2
|
+
import { ComponentX } from '../components/BaseComponent';
|
|
3
|
+
import { loadIsometricMap } from './tield';
|
|
4
|
+
export class TiledMapComp extends ComponentX {
|
|
5
|
+
getPositionAt(x, ty) {
|
|
6
|
+
const mapData = this.mapData;
|
|
7
|
+
const tx = x + 1;
|
|
8
|
+
// Chuyển sang toạ độ isometric
|
|
9
|
+
const screenX = (tx - ty) * (mapData.tilewidth / 2);
|
|
10
|
+
const screenY = (tx + ty) * (mapData.tileheight / 2);
|
|
11
|
+
return Vec2(screenX, screenY);
|
|
12
|
+
}
|
|
13
|
+
render() {
|
|
14
|
+
this.mapData = Assets.get(this.props.mapFile);
|
|
15
|
+
const tiledMap = loadIsometricMap(this.props.mapFile);
|
|
16
|
+
const world = GameWorld.Instance;
|
|
17
|
+
const entity = world.entities.create();
|
|
18
|
+
entity.assign(new NodeComp(tiledMap, entity));
|
|
19
|
+
const comp = entity.assign(this);
|
|
20
|
+
return comp;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tiledmap/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,SAE5B"}
|
|
@@ -0,0 +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,gBAAgB,CAAC,MAAM,EAAE,MAAM,WAoC9C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Tilemap } from '@pixi/tilemap';
|
|
2
|
+
import { Assets, Rectangle, Texture } from 'pixi.js';
|
|
3
|
+
export function loadIsometricMap(mapUrl) {
|
|
4
|
+
const mapData = Assets.get(mapUrl);
|
|
5
|
+
const tileset = mapData.tilesets[0];
|
|
6
|
+
const baseDir = mapUrl.split('/').slice(0, -1).join('/');
|
|
7
|
+
const tilesetImageUrl = `${baseDir}/${tileset.image}`;
|
|
8
|
+
const tilesetTexture = Assets.get(tilesetImageUrl);
|
|
9
|
+
const baseTexture = tilesetTexture.baseTexture;
|
|
10
|
+
const tileW = tileset.tilewidth;
|
|
11
|
+
const tileH = tileset.tileheight;
|
|
12
|
+
const cols = tileset.columns;
|
|
13
|
+
const firstGid = tileset.firstgid;
|
|
14
|
+
const tilemap = new Tilemap(baseTexture);
|
|
15
|
+
for (const layer of mapData.layers) {
|
|
16
|
+
if (layer.type !== 'tilelayer')
|
|
17
|
+
continue;
|
|
18
|
+
const data = layer.data;
|
|
19
|
+
for (let i = 0; i < data.length; i++) {
|
|
20
|
+
const gid = data[i];
|
|
21
|
+
if (gid === 0)
|
|
22
|
+
continue;
|
|
23
|
+
const tileId = gid - firstGid;
|
|
24
|
+
const frameX = (tileId % cols) * tileW;
|
|
25
|
+
const frameY = Math.floor(tileId / cols) * tileH;
|
|
26
|
+
const tx = i % mapData.width;
|
|
27
|
+
const ty = Math.floor(i / mapData.width);
|
|
28
|
+
// Chuyển sang toạ độ isometric
|
|
29
|
+
const screenX = (tx - ty) * (mapData.tilewidth / 2);
|
|
30
|
+
const screenY = (tx + ty) * (mapData.tileheight / 2);
|
|
31
|
+
const texture = new Texture({ source: baseTexture, frame: new Rectangle(frameX, frameY, tileW, tileH) });
|
|
32
|
+
tilemap.tile(texture, screenX, screenY);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return tilemap;
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@safe-engine/pixi",
|
|
3
|
-
"version": "8.8.
|
|
3
|
+
"version": "8.8.7",
|
|
4
4
|
"description": "safex pixi plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@esotericsoftware/spine-core": "^4.2.94",
|
|
21
|
+
"@pixi/tilemap": "^5.0.2",
|
|
21
22
|
"@pixi/ui": "^2.2.7",
|
|
22
23
|
"box2d-wasm": "^7.0.0",
|
|
23
24
|
"entityx-ts": "^2.3.1",
|