emeraldengine 2.2.1 → 3.1.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/README.md +2198 -968
- package/dist/types/index.d.ts +75 -32
- package/dist/types/src/Animator.d.ts +50 -0
- package/dist/types/{BitmapText.d.ts → src/BitmapText.d.ts} +19 -21
- package/dist/types/src/Camera.d.ts +122 -0
- package/dist/types/src/CameraController.d.ts +107 -0
- package/dist/types/src/CanvasText.d.ts +91 -0
- package/dist/types/src/CollisionLayers.d.ts +58 -0
- package/dist/types/{Color.d.ts → src/Color.d.ts} +6 -6
- package/dist/types/src/Coroutine.d.ts +111 -0
- package/dist/types/src/DebugOverlay.d.ts +86 -0
- package/dist/types/src/Drawable.d.ts +271 -0
- package/dist/types/src/Easing.d.ts +22 -0
- package/dist/types/src/Emerald.d.ts +420 -0
- package/dist/types/src/EmeraldDB.d.ts +159 -0
- package/dist/types/{FPSCounter.d.ts → src/FPSCounter.d.ts} +1 -3
- package/dist/types/src/GLUtils.d.ts +4 -0
- package/dist/types/{Instance.d.ts → src/Instance.d.ts} +37 -15
- package/dist/types/{InstancedTexture.d.ts → src/InstancedTexture.d.ts} +75 -23
- package/dist/types/src/Interpolator.d.ts +66 -0
- package/dist/types/src/Material.d.ts +87 -0
- package/dist/types/src/MathUtils.d.ts +81 -0
- package/dist/types/src/ParticleEmitter.d.ts +131 -0
- package/dist/types/src/Physics.d.ts +337 -0
- package/dist/types/src/Pool.d.ts +53 -0
- package/dist/types/src/PostEffects.d.ts +68 -0
- package/dist/types/src/PostProcessor.d.ts +124 -0
- package/dist/types/src/RenderTarget.d.ts +56 -0
- package/dist/types/src/Scene.d.ts +62 -0
- package/dist/types/src/ScreenEffects.d.ts +111 -0
- package/dist/types/src/Serializer.d.ts +86 -0
- package/dist/types/src/Shaders.d.ts +2 -0
- package/dist/types/{Shapes.d.ts → src/Shapes.d.ts} +4 -6
- package/dist/types/src/SpatialGrid.d.ts +50 -0
- package/dist/types/src/SpriteBatch.d.ts +89 -0
- package/dist/types/src/StateMachine.d.ts +59 -0
- package/dist/types/src/Storage.d.ts +89 -0
- package/dist/types/{Texture.d.ts → src/Texture.d.ts} +3 -4
- package/dist/types/src/TextureAtlas.d.ts +55 -0
- package/dist/types/src/Tilemap.d.ts +91 -0
- package/dist/types/src/Time.d.ts +53 -0
- package/dist/types/src/Timer.d.ts +54 -0
- package/dist/types/src/Transform.d.ts +94 -0
- package/dist/types/src/Tween.d.ts +81 -0
- package/dist/types/src/UI.d.ts +121 -0
- package/dist/types/src/components/Behaviour.d.ts +71 -0
- package/dist/types/{components → src/components}/BoxCollider.d.ts +14 -14
- package/dist/types/src/components/BoxColliderDebug.d.ts +15 -0
- package/dist/types/{components → src/components}/CircleCollider.d.ts +14 -12
- package/dist/types/src/components/CircleColliderDebug.d.ts +15 -0
- package/dist/types/src/components/Collider.d.ts +102 -0
- package/dist/types/src/components/GameObject.d.ts +135 -0
- package/dist/types/src/components/PolygonCollider.d.ts +33 -0
- package/dist/types/src/components/RigidBody.d.ts +456 -0
- package/dist/types/src/importers/Aseprite.d.ts +79 -0
- package/dist/types/src/importers/ForgeLevel.d.ts +97 -0
- package/dist/types/src/importers/TiledMap.d.ts +62 -0
- package/dist/types/{lights → src/lights}/DirectionalLight.d.ts +7 -9
- package/dist/types/{lights → src/lights}/PointLight.d.ts +6 -9
- package/dist/types/src/managers/AssetManager.d.ts +116 -0
- package/dist/types/src/managers/AudioManager.d.ts +259 -0
- package/dist/types/{managers → src/managers}/CameraManager.d.ts +8 -8
- package/dist/types/{managers → src/managers}/EventManager.d.ts +46 -32
- package/dist/types/src/managers/GLManager.d.ts +84 -0
- package/dist/types/src/managers/GLState.d.ts +37 -0
- package/dist/types/src/managers/Gamepad.d.ts +102 -0
- package/dist/types/src/managers/IDManager.d.ts +31 -0
- package/dist/types/src/managers/InputManager.d.ts +381 -0
- package/dist/types/src/managers/NetworkManager.d.ts +93 -0
- package/dist/types/src/managers/RenderStats.d.ts +34 -0
- package/dist/types/src/managers/SceneManager.d.ts +44 -0
- package/dist/types/src/managers/ShaderManager.d.ts +55 -0
- package/dist/types/src/managers/TextureManager.d.ts +102 -0
- package/dist/types/src/particlesystem/Particle.d.ts +64 -0
- package/dist/types/{particlesystem → src/particlesystem}/ParticleSettings.d.ts +32 -24
- package/dist/types/{particlesystem → src/particlesystem}/Particles.d.ts +20 -12
- package/dist/types/src/physics/AABB.d.ts +92 -0
- package/dist/types/src/physics/Body.d.ts +435 -0
- package/dist/types/src/physics/BodyType.d.ts +6 -0
- package/dist/types/src/physics/BroadPhase.d.ts +210 -0
- package/dist/types/src/physics/Collision.d.ts +102 -0
- package/dist/types/src/physics/Contact.d.ts +206 -0
- package/dist/types/src/physics/ContactSolver.d.ts +108 -0
- package/dist/types/src/physics/Distance.d.ts +54 -0
- package/dist/types/src/physics/DistanceJoint.d.ts +90 -0
- package/dist/types/src/physics/Fixture.d.ts +221 -0
- package/dist/types/src/physics/Island.d.ts +52 -0
- package/dist/types/src/physics/Joint.d.ts +59 -0
- package/dist/types/src/physics/Math2D.d.ts +371 -0
- package/dist/types/src/physics/RevoluteJoint.d.ts +119 -0
- package/dist/types/src/physics/Settings.d.ts +22 -0
- package/dist/types/src/physics/Shapes.d.ts +207 -0
- package/dist/types/src/physics/TimeOfImpact.d.ts +22 -0
- package/dist/types/src/physics/World.d.ts +274 -0
- package/dist/types/src/physics/index.d.ts +34 -0
- package/index.js +78 -0
- package/package.json +73 -60
- package/src/Animator.js +95 -0
- package/src/BitmapText.js +6 -5
- package/src/Camera.js +183 -0
- package/src/CameraController.js +192 -0
- package/src/CanvasText.js +281 -0
- package/src/CollisionLayers.js +86 -0
- package/src/Color.js +26 -18
- package/src/Coroutine.js +259 -0
- package/src/DebugOverlay.js +246 -0
- package/src/Drawable.js +842 -582
- package/src/Easing.js +57 -0
- package/src/Emerald.js +1150 -459
- package/src/EmeraldDB.js +328 -0
- package/src/FPSCounter.js +43 -43
- package/src/GLUtils.js +60 -67
- package/src/Instance.js +41 -5
- package/src/InstancedTexture.js +308 -127
- package/src/Interpolator.js +124 -0
- package/src/Material.js +202 -0
- package/src/MathUtils.js +134 -0
- package/src/ParticleEmitter.js +284 -0
- package/src/Physics.js +431 -40
- package/src/Pool.js +85 -0
- package/src/PostEffects.js +296 -0
- package/src/PostProcessor.js +304 -0
- package/src/RenderTarget.js +134 -0
- package/src/Scene.js +115 -83
- package/src/ScreenEffects.js +266 -0
- package/src/Serializer.js +131 -0
- package/src/Shaders.js +150 -165
- package/src/Shapes.js +118 -129
- package/src/SpatialGrid.js +111 -0
- package/src/SpriteBatch.js +299 -0
- package/src/StateMachine.js +82 -0
- package/src/Storage.js +175 -47
- package/src/Texture.js +58 -67
- package/src/TextureAtlas.js +96 -0
- package/src/Tilemap.js +274 -0
- package/src/Time.js +51 -6
- package/src/Timer.js +99 -0
- package/src/Transform.js +100 -7
- package/src/Tween.js +160 -0
- package/src/UI.js +394 -0
- package/src/components/Behaviour.js +90 -0
- package/src/components/BoxCollider.js +29 -12
- package/src/components/BoxColliderDebug.js +3 -4
- package/src/components/CircleCollider.js +26 -12
- package/src/components/CircleColliderDebug.js +25 -24
- package/src/components/Collider.js +150 -34
- package/src/components/GameObject.js +130 -21
- package/src/components/PolygonCollider.js +55 -0
- package/src/components/RigidBody.js +556 -8
- package/src/importers/Aseprite.js +142 -0
- package/src/importers/ForgeLevel.js +581 -0
- package/src/importers/TiledMap.js +158 -0
- package/src/lights/DirectionalLight.js +6 -15
- package/src/lights/PointLight.js +4 -4
- package/src/managers/AssetManager.js +239 -0
- package/src/managers/AudioManager.js +565 -146
- package/src/managers/EventManager.js +488 -477
- package/src/managers/GLManager.js +57 -0
- package/src/managers/GLState.js +70 -0
- package/src/managers/Gamepad.js +126 -0
- package/src/managers/IDManager.js +24 -2
- package/src/managers/InputManager.js +905 -0
- package/src/managers/NetworkManager.js +178 -0
- package/src/managers/RenderStats.js +34 -0
- package/src/managers/SceneManager.js +30 -0
- package/src/managers/ShaderManager.js +0 -2
- package/src/managers/TextureManager.js +218 -0
- package/src/particlesystem/Particle.js +82 -7
- package/src/particlesystem/ParticleSettings.js +21 -3
- package/src/particlesystem/Particles.js +80 -31
- package/src/physics/AABB.js +207 -0
- package/src/physics/Body.js +862 -0
- package/src/physics/BodyType.js +16 -0
- package/src/physics/BroadPhase.js +641 -0
- package/src/physics/Collision.js +534 -0
- package/src/physics/Contact.js +500 -0
- package/src/physics/ContactSolver.js +526 -0
- package/src/physics/Distance.js +403 -0
- package/src/physics/DistanceJoint.js +227 -0
- package/src/physics/Fixture.js +346 -0
- package/src/physics/Island.js +203 -0
- package/src/physics/Joint.js +78 -0
- package/src/physics/Math2D.js +573 -0
- package/src/physics/RevoluteJoint.js +278 -0
- package/src/physics/Settings.js +78 -0
- package/src/physics/Shapes.js +549 -0
- package/src/physics/TimeOfImpact.js +87 -0
- package/src/physics/World.js +731 -0
- package/src/physics/index.js +79 -0
- package/dist/types/Drawable.d.ts +0 -157
- package/dist/types/Emerald.d.ts +0 -73
- package/dist/types/GLUtils.d.ts +0 -6
- package/dist/types/Physics.d.ts +0 -139
- package/dist/types/Scene.d.ts +0 -39
- package/dist/types/Shaders.d.ts +0 -4
- package/dist/types/Storage.d.ts +0 -46
- package/dist/types/Time.d.ts +0 -22
- package/dist/types/Transform.d.ts +0 -41
- package/dist/types/components/BoxColliderDebug.d.ts +0 -19
- package/dist/types/components/CircleColliderDebug.d.ts +0 -19
- package/dist/types/components/Collider.d.ts +0 -53
- package/dist/types/components/GameObject.d.ts +0 -72
- package/dist/types/components/RigidBody.d.ts +0 -104
- package/dist/types/managers/AudioManager.d.ts +0 -60
- package/dist/types/managers/GLManager.d.ts +0 -47
- package/dist/types/managers/IDManager.d.ts +0 -21
- package/dist/types/managers/SceneManager.d.ts +0 -22
- package/dist/types/particlesystem/Particle.d.ts +0 -42
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
export default RigidBody;
|
|
2
|
+
/**
|
|
3
|
+
* @class RigidBody
|
|
4
|
+
* @description The game-facing physics body: everything you can do to a body
|
|
5
|
+
* (move it, push it, spin it, sleep it, query its mass) is a method on this
|
|
6
|
+
* class directly, in world/pixel units. There is no separate lower-level
|
|
7
|
+
* body object you need to fetch first. `getBody()` still returns the raw,
|
|
8
|
+
* physics-unit {@link Body} underneath for the rare case you need it (writing
|
|
9
|
+
* a custom joint, say), but nothing in ordinary use requires it.
|
|
10
|
+
* @param {Physics} physics - The physics engine
|
|
11
|
+
* @param {string | "static" | "dynamic" | "kinematic"} type - The type of rigidbody
|
|
12
|
+
* @param {Vector2} position - The position of the rigidbody
|
|
13
|
+
* @param {boolean} fixedRotation - Whether the rigidbody is fixed rotation
|
|
14
|
+
* @param {GameObject} parentObject - The parent object of the rigidbody
|
|
15
|
+
* @param {Vector2} offset - The offset of the rigidbody
|
|
16
|
+
*/
|
|
17
|
+
declare class RigidBody {
|
|
18
|
+
constructor(physics: any, type: any, position: any, fixedRotation: any, parentObject?: any, offset?: Vector2);
|
|
19
|
+
physics: any;
|
|
20
|
+
offset: Vector2;
|
|
21
|
+
type: any;
|
|
22
|
+
body: any;
|
|
23
|
+
parentObject: any;
|
|
24
|
+
position: any;
|
|
25
|
+
collider: Collider;
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
/** Freely usable by your own code; see {@link RigidBody#getUserData}. */
|
|
29
|
+
userData: any;
|
|
30
|
+
/**
|
|
31
|
+
* @method updatePosition
|
|
32
|
+
* @description Updates the position of the rigidbody
|
|
33
|
+
* @param {Vector2} position - The new position
|
|
34
|
+
*/
|
|
35
|
+
updatePosition(position: Vector2): void;
|
|
36
|
+
/**
|
|
37
|
+
* @method setPosition
|
|
38
|
+
* @description Alias of {@link RigidBody#updatePosition}, named to match
|
|
39
|
+
* `setRotation`/`setTransform`.
|
|
40
|
+
* @param {Vector2} position - The new position, in world (pixel) units
|
|
41
|
+
*/
|
|
42
|
+
setPosition(position: Vector2): void;
|
|
43
|
+
/**
|
|
44
|
+
* @method setTransform
|
|
45
|
+
* @description Teleports the body to a new position and angle in one move
|
|
46
|
+
* (no velocity implied), and wakes it so contacts at the new spot are seen
|
|
47
|
+
* on the very next step.
|
|
48
|
+
* @param {Vector2} position - World (pixel) units
|
|
49
|
+
* @param {number} angle - Radians
|
|
50
|
+
*/
|
|
51
|
+
setTransform(position: Vector2, angle: number): void;
|
|
52
|
+
/**
|
|
53
|
+
* @method getWorldX
|
|
54
|
+
* @description The single source of truth for body(physics) -> world(pixel)
|
|
55
|
+
* conversion on X: undo the scale and the spawn offset.
|
|
56
|
+
* @returns {number} - The live world-space x of the body
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
private getWorldX;
|
|
60
|
+
/**
|
|
61
|
+
* @method getWorldY
|
|
62
|
+
* @description World-space y counterpart of getWorldX.
|
|
63
|
+
* @returns {number} - The live world-space y of the body
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
private getWorldY;
|
|
67
|
+
/**
|
|
68
|
+
* @method syncTransform
|
|
69
|
+
* @description Writes the body's live world position and angle into a
|
|
70
|
+
* Transform. This is the one place body state is copied onto a renderable, so
|
|
71
|
+
* position and rotation stay in lock-step. Static/kinematic bodies are not
|
|
72
|
+
* driven by the simulation, so only dynamic bodies write back.
|
|
73
|
+
* @param {Transform} transform - The transform to update in place
|
|
74
|
+
*/
|
|
75
|
+
syncTransform(transform: Transform): void;
|
|
76
|
+
/**
|
|
77
|
+
* @method getOffset
|
|
78
|
+
* @description Returns the offset of the rigidbody
|
|
79
|
+
* @returns {Vector2} - The offset of the rigidbody
|
|
80
|
+
*/
|
|
81
|
+
getOffset(): Vector2;
|
|
82
|
+
/**
|
|
83
|
+
* @method setCollider
|
|
84
|
+
* @description Sets the collider of the rigidbody
|
|
85
|
+
* @param {Collider} collider - The collider to set
|
|
86
|
+
*/
|
|
87
|
+
setCollider(collider: Collider): void;
|
|
88
|
+
/**
|
|
89
|
+
* @method createFixture
|
|
90
|
+
* @description Attaches a shape directly, bypassing the Collider component
|
|
91
|
+
* classes ({@link BoxCollider}, {@link CircleCollider}, {@link PolygonCollider})
|
|
92
|
+
* that normally build one for you. `shape` is a physics-unit shape (e.g. from
|
|
93
|
+
* `Box()`/`Circle()`/`new PolygonShape()`), not pixels.
|
|
94
|
+
* @param {Shape} shape
|
|
95
|
+
* @param {Object|number} [def] - `{ density, friction, restitution, isSensor, ... }`
|
|
96
|
+
* @returns {Fixture}
|
|
97
|
+
*/
|
|
98
|
+
createFixture(shape: Shape, def?: any | number): Fixture;
|
|
99
|
+
/**
|
|
100
|
+
* @method destroyFixture
|
|
101
|
+
* @description Removes a fixture created with {@link RigidBody#createFixture}.
|
|
102
|
+
* @param {Fixture} fixture
|
|
103
|
+
*/
|
|
104
|
+
destroyFixture(fixture: Fixture): void;
|
|
105
|
+
/**
|
|
106
|
+
* @method setRotation
|
|
107
|
+
* @description Sets the rotation of the rigidbody
|
|
108
|
+
* @param {number} rotation - The new rotation
|
|
109
|
+
*/
|
|
110
|
+
setRotation(rotation: number): void;
|
|
111
|
+
/**
|
|
112
|
+
* @method setLinearVelocity
|
|
113
|
+
* @description Sets the body's linear velocity in world (pixel) units per
|
|
114
|
+
* second. Converts to physics units internally.
|
|
115
|
+
* @param {number} vx - Horizontal velocity (world units/sec)
|
|
116
|
+
* @param {number} vy - Vertical velocity (world units/sec)
|
|
117
|
+
*/
|
|
118
|
+
setLinearVelocity(vx: number, vy: number): void;
|
|
119
|
+
/**
|
|
120
|
+
* @method getLinearVelocity
|
|
121
|
+
* @description Returns the body's linear velocity in world (pixel) units/sec.
|
|
122
|
+
* @returns {{x:number, y:number}}
|
|
123
|
+
*/
|
|
124
|
+
getLinearVelocity(): {
|
|
125
|
+
x: number;
|
|
126
|
+
y: number;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* @method getLinearVelocityFromWorldPoint
|
|
130
|
+
* @description The velocity (world units/sec) of the material point of this
|
|
131
|
+
* body currently at `worldPoint`: linear velocity plus the contribution
|
|
132
|
+
* from spin. Useful for e.g. where a spinning platform's edge is moving.
|
|
133
|
+
* @param {Object} worldPoint - World (pixel) units
|
|
134
|
+
* @returns {Vector2}
|
|
135
|
+
*/
|
|
136
|
+
getLinearVelocityFromWorldPoint(worldPoint: any): Vector2;
|
|
137
|
+
/**
|
|
138
|
+
* @method setAngularVelocity
|
|
139
|
+
* @description Sets the body's spin, in radians per second.
|
|
140
|
+
* @param {number} omega
|
|
141
|
+
*/
|
|
142
|
+
setAngularVelocity(omega: number): void;
|
|
143
|
+
/**
|
|
144
|
+
* @method getAngularVelocity
|
|
145
|
+
* @description Returns the body's spin, in radians per second.
|
|
146
|
+
* @returns {number}
|
|
147
|
+
*/
|
|
148
|
+
getAngularVelocity(): number;
|
|
149
|
+
/**
|
|
150
|
+
* @method applyImpulse
|
|
151
|
+
* @description Applies an instantaneous change in momentum (world units).
|
|
152
|
+
* This is what a jump or a knockback should use, since (unlike a force) it
|
|
153
|
+
* takes effect immediately rather than accumulating over the step.
|
|
154
|
+
* @param {number} ix
|
|
155
|
+
* @param {number} iy
|
|
156
|
+
* @param {Object} [point] - World (pixel) point to apply it at; defaults to
|
|
157
|
+
* the center of mass (no torque)
|
|
158
|
+
* @param {boolean} [wake=true]
|
|
159
|
+
*/
|
|
160
|
+
applyImpulse(ix: number, iy: number, point?: any, wake?: boolean): void;
|
|
161
|
+
/**
|
|
162
|
+
* @method applyAngularImpulse
|
|
163
|
+
* @description Applies an instantaneous change in angular momentum.
|
|
164
|
+
* @param {number} impulse
|
|
165
|
+
* @param {boolean} [wake=true]
|
|
166
|
+
*/
|
|
167
|
+
applyAngularImpulse(impulse: number, wake?: boolean): void;
|
|
168
|
+
/**
|
|
169
|
+
* @method applyForce
|
|
170
|
+
* @description Applies a force (world units) at a world point. Forces
|
|
171
|
+
* accumulate and are cleared at the end of every step, so this belongs in
|
|
172
|
+
* your update loop, unlike an impulse.
|
|
173
|
+
* @param {number} fx
|
|
174
|
+
* @param {number} fy
|
|
175
|
+
* @param {Object} [point] - World (pixel) point; defaults to the center of
|
|
176
|
+
* mass (no torque)
|
|
177
|
+
* @param {boolean} [wake=true]
|
|
178
|
+
*/
|
|
179
|
+
applyForce(fx: number, fy: number, point?: any, wake?: boolean): void;
|
|
180
|
+
/**
|
|
181
|
+
* @method applyForceToCenter
|
|
182
|
+
* @description Applies a force (world units) at the center of mass: no
|
|
183
|
+
* torque, unlike {@link RigidBody#applyForce} with a point.
|
|
184
|
+
* @param {number} fx
|
|
185
|
+
* @param {number} fy
|
|
186
|
+
* @param {boolean} [wake=true]
|
|
187
|
+
*/
|
|
188
|
+
applyForceToCenter(fx: number, fy: number, wake?: boolean): void;
|
|
189
|
+
/**
|
|
190
|
+
* @method applyTorque
|
|
191
|
+
* @description Applies a torque about the center of mass.
|
|
192
|
+
* @param {number} torque
|
|
193
|
+
* @param {boolean} [wake=true]
|
|
194
|
+
*/
|
|
195
|
+
applyTorque(torque: number, wake?: boolean): void;
|
|
196
|
+
/**
|
|
197
|
+
* @method setAwake
|
|
198
|
+
* @description Wakes or sleeps the body.
|
|
199
|
+
* @param {boolean} awake
|
|
200
|
+
*/
|
|
201
|
+
setAwake(awake: boolean): void;
|
|
202
|
+
/**
|
|
203
|
+
* @method isAwake
|
|
204
|
+
* @description Whether the body is currently simulated.
|
|
205
|
+
* @returns {boolean}
|
|
206
|
+
*/
|
|
207
|
+
isAwake(): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* @method setSleepingAllowed
|
|
210
|
+
* @description Allows or forbids this body from ever sleeping.
|
|
211
|
+
* @param {boolean} flag
|
|
212
|
+
*/
|
|
213
|
+
setSleepingAllowed(flag: boolean): void;
|
|
214
|
+
/**
|
|
215
|
+
* @method isSleepingAllowed
|
|
216
|
+
* @returns {boolean}
|
|
217
|
+
*/
|
|
218
|
+
isSleepingAllowed(): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* @method setActive
|
|
221
|
+
* @description Adds or removes the body from collision detection without
|
|
222
|
+
* destroying it.
|
|
223
|
+
* @param {boolean} flag
|
|
224
|
+
*/
|
|
225
|
+
setActive(flag: boolean): void;
|
|
226
|
+
/**
|
|
227
|
+
* @method isActive
|
|
228
|
+
* @returns {boolean}
|
|
229
|
+
*/
|
|
230
|
+
isActive(): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* @method setFixedRotation
|
|
233
|
+
* @description Locks or unlocks the body's rotation at runtime.
|
|
234
|
+
* @param {boolean} flag
|
|
235
|
+
*/
|
|
236
|
+
setFixedRotation(flag: boolean): void;
|
|
237
|
+
/**
|
|
238
|
+
* @method isFixedRotation
|
|
239
|
+
* @returns {boolean}
|
|
240
|
+
*/
|
|
241
|
+
isFixedRotation(): boolean;
|
|
242
|
+
/**
|
|
243
|
+
* @method setContinuous
|
|
244
|
+
* @description Enables continuous collision detection (CCD) for this body by
|
|
245
|
+
* marking it a "bullet". Fast-moving bodies (e.g. a dash, a projectile, a
|
|
246
|
+
* player falling at high speed) otherwise sweep so far in a single fixed step
|
|
247
|
+
* that they tunnel straight through thin static geometry; with CCD on, the
|
|
248
|
+
* engine sweeps the body against static geometry so it stops at the wall
|
|
249
|
+
* instead of teleporting past it. Costs more per step, so reserve it for the
|
|
250
|
+
* handful of bodies that actually move fast.
|
|
251
|
+
* @param {boolean} [enabled=true]
|
|
252
|
+
* @returns {RigidBody} - this
|
|
253
|
+
*/
|
|
254
|
+
setContinuous(enabled?: boolean): RigidBody;
|
|
255
|
+
/**
|
|
256
|
+
* @method isContinuous
|
|
257
|
+
* @description Whether CCD (bullet mode) is enabled for this body.
|
|
258
|
+
* @returns {boolean}
|
|
259
|
+
*/
|
|
260
|
+
isContinuous(): boolean;
|
|
261
|
+
/**
|
|
262
|
+
* @method setLinearDamping
|
|
263
|
+
* @description Sets the drag applied to linear motion each step.
|
|
264
|
+
* @param {number} damping
|
|
265
|
+
*/
|
|
266
|
+
setLinearDamping(damping: number): void;
|
|
267
|
+
/**
|
|
268
|
+
* @method getLinearDamping
|
|
269
|
+
* @returns {number}
|
|
270
|
+
*/
|
|
271
|
+
getLinearDamping(): number;
|
|
272
|
+
/**
|
|
273
|
+
* @method setAngularDamping
|
|
274
|
+
* @description Sets the drag applied to rotation each step.
|
|
275
|
+
* @param {number} damping
|
|
276
|
+
*/
|
|
277
|
+
setAngularDamping(damping: number): void;
|
|
278
|
+
/**
|
|
279
|
+
* @method getAngularDamping
|
|
280
|
+
* @returns {number}
|
|
281
|
+
*/
|
|
282
|
+
getAngularDamping(): number;
|
|
283
|
+
/**
|
|
284
|
+
* @method setGravityScale
|
|
285
|
+
* @description Scales how strongly gravity pulls on this body (0 disables
|
|
286
|
+
* it, 2 makes it twice as heavy-feeling).
|
|
287
|
+
* @param {number} scale
|
|
288
|
+
*/
|
|
289
|
+
setGravityScale(scale: number): void;
|
|
290
|
+
/**
|
|
291
|
+
* @method getGravityScale
|
|
292
|
+
* @returns {number}
|
|
293
|
+
*/
|
|
294
|
+
getGravityScale(): number;
|
|
295
|
+
/**
|
|
296
|
+
* @method getMass
|
|
297
|
+
* @description Returns the body's mass, in physics units (derived from its
|
|
298
|
+
* fixtures' shapes and densities, unaffected by the pixel scale).
|
|
299
|
+
* @returns {number}
|
|
300
|
+
*/
|
|
301
|
+
getMass(): number;
|
|
302
|
+
/**
|
|
303
|
+
* @method getInertia
|
|
304
|
+
* @description Returns the body's rotational inertia about its center of
|
|
305
|
+
* mass, in physics units.
|
|
306
|
+
* @returns {number}
|
|
307
|
+
*/
|
|
308
|
+
getInertia(): number;
|
|
309
|
+
/**
|
|
310
|
+
* @method resetMassData
|
|
311
|
+
* @description Re-derives mass/center/inertia from the body's current
|
|
312
|
+
* fixtures. Call this after changing a fixture's density at runtime.
|
|
313
|
+
*/
|
|
314
|
+
resetMassData(): void;
|
|
315
|
+
/**
|
|
316
|
+
* @method setMassData
|
|
317
|
+
* @description Overrides the computed mass properties directly.
|
|
318
|
+
* @param {Object} massData - `{ mass, center, I }`; `center` is a world
|
|
319
|
+
* (pixel) offset from the body's origin
|
|
320
|
+
*/
|
|
321
|
+
setMassData(massData: any): void;
|
|
322
|
+
/**
|
|
323
|
+
* @method getWorldPoint
|
|
324
|
+
* @description Converts a point local to this body into world (pixel) space.
|
|
325
|
+
* @param {Object} localPoint - World-unit offset from the body's origin
|
|
326
|
+
* @returns {Vector2}
|
|
327
|
+
*/
|
|
328
|
+
getWorldPoint(localPoint: any): Vector2;
|
|
329
|
+
/**
|
|
330
|
+
* @method getLocalPoint
|
|
331
|
+
* @description Converts a world (pixel) point into this body's local frame.
|
|
332
|
+
* @param {Object} worldPoint - World (pixel) units
|
|
333
|
+
* @returns {Vector2}
|
|
334
|
+
*/
|
|
335
|
+
getLocalPoint(worldPoint: any): Vector2;
|
|
336
|
+
/**
|
|
337
|
+
* @method getWorldVector
|
|
338
|
+
* @description Rotates a local direction (not a point, unaffected by the
|
|
339
|
+
* body's position) into world space.
|
|
340
|
+
* @param {Object} localVector
|
|
341
|
+
* @returns {Vector2}
|
|
342
|
+
*/
|
|
343
|
+
getWorldVector(localVector: any): Vector2;
|
|
344
|
+
/**
|
|
345
|
+
* @method getLocalVector
|
|
346
|
+
* @description Rotates a world direction into this body's local frame.
|
|
347
|
+
* @param {Object} worldVector
|
|
348
|
+
* @returns {Vector2}
|
|
349
|
+
*/
|
|
350
|
+
getLocalVector(worldVector: any): Vector2;
|
|
351
|
+
/**
|
|
352
|
+
* @method getContactList
|
|
353
|
+
* @description Returns the raw physics contacts this body currently takes
|
|
354
|
+
* part in. Each contact's `fixtureA`/`fixtureB` point at physics-unit
|
|
355
|
+
* fixtures/bodies, not RigidBody wrappers. Walk `fixture.body.getUserData()`
|
|
356
|
+
* to get back to the owning RigidBody.
|
|
357
|
+
* @returns {Array<Contact>}
|
|
358
|
+
*/
|
|
359
|
+
getContactList(): Array<Contact>;
|
|
360
|
+
/**
|
|
361
|
+
* @method getWorld
|
|
362
|
+
* @description Returns the raw physics {@link World} this body lives in.
|
|
363
|
+
* @returns {World}
|
|
364
|
+
*/
|
|
365
|
+
getWorld(): World;
|
|
366
|
+
/**
|
|
367
|
+
* @method getUserData
|
|
368
|
+
* @description Returns whatever you last passed to
|
|
369
|
+
* {@link RigidBody#setUserData}. This is separate from the underlying
|
|
370
|
+
* physics body's own userData slot, which the engine itself uses internally
|
|
371
|
+
* to route collisions back to this RigidBody, so setting it here can never
|
|
372
|
+
* break that.
|
|
373
|
+
* @returns {*}
|
|
374
|
+
*/
|
|
375
|
+
getUserData(): any;
|
|
376
|
+
/**
|
|
377
|
+
* @method setUserData
|
|
378
|
+
* @param {*} data
|
|
379
|
+
*/
|
|
380
|
+
setUserData(data: any): void;
|
|
381
|
+
/**
|
|
382
|
+
* @method getPosition
|
|
383
|
+
* @description Returns the live world-space position of the body (kept in sync
|
|
384
|
+
* with the simulation), not the spawn position. Use getInitialPosition() for
|
|
385
|
+
* the position the body was created at.
|
|
386
|
+
* @returns {Vector2} - The current world-space position of the rigidbody
|
|
387
|
+
*/
|
|
388
|
+
getPosition(): Vector2;
|
|
389
|
+
/**
|
|
390
|
+
* @method getInitialPosition
|
|
391
|
+
* @description Returns the world-space position the body was created at.
|
|
392
|
+
* @returns {Vector2} - The spawn position of the rigidbody
|
|
393
|
+
*/
|
|
394
|
+
getInitialPosition(): Vector2;
|
|
395
|
+
/**
|
|
396
|
+
* @method getAngle
|
|
397
|
+
* @description Returns the angle of the rigidbody
|
|
398
|
+
* @returns {number} - The angle of the rigidbody
|
|
399
|
+
*/
|
|
400
|
+
getAngle(): number;
|
|
401
|
+
/**
|
|
402
|
+
* @method getCollider
|
|
403
|
+
* @description Returns the collider of the rigidbody
|
|
404
|
+
* @returns {Collider} - The collider of the rigidbody
|
|
405
|
+
*/
|
|
406
|
+
getCollider(): Collider;
|
|
407
|
+
/**
|
|
408
|
+
* @method getBody
|
|
409
|
+
* @description Returns the underlying, physics-unit {@link Body}. Nothing in
|
|
410
|
+
* ordinary use needs this: every common operation is a method on RigidBody
|
|
411
|
+
* itself, in world/pixel units, but it's here for advanced cases (writing a
|
|
412
|
+
* custom joint or solver hook) that need the raw physics object.
|
|
413
|
+
* @returns {Body} - The body of the rigidbody
|
|
414
|
+
*/
|
|
415
|
+
getBody(): Body;
|
|
416
|
+
/**
|
|
417
|
+
* @method getPhysics
|
|
418
|
+
* @description Returns the physics engine of the rigidbody
|
|
419
|
+
* @returns {Physics} - The physics engine of the rigidbody
|
|
420
|
+
*/
|
|
421
|
+
getPhysics(): Physics;
|
|
422
|
+
/**
|
|
423
|
+
* @method destroy
|
|
424
|
+
* @description Destroys the rigidbody
|
|
425
|
+
*/
|
|
426
|
+
destroy(): void;
|
|
427
|
+
/**
|
|
428
|
+
* @method detachCollider
|
|
429
|
+
* @description Detaches a collider from the rigidbody
|
|
430
|
+
* @param {Collider} collider - The collider to detach
|
|
431
|
+
*/
|
|
432
|
+
detachCollider(collider: Collider): void;
|
|
433
|
+
/**
|
|
434
|
+
* @method setParent
|
|
435
|
+
* @description Sets the parent object of the rigidbody
|
|
436
|
+
* @param {GameObject} parent - The parent object to set
|
|
437
|
+
*/
|
|
438
|
+
setParent(parent: GameObject): void;
|
|
439
|
+
/**
|
|
440
|
+
* @method getType
|
|
441
|
+
* @description Returns the type of the rigidbody
|
|
442
|
+
* @returns {string | "static" | "dynamic" | "kinematic"} - The type of the rigidbody
|
|
443
|
+
*/
|
|
444
|
+
getType(): string | "static" | "dynamic" | "kinematic";
|
|
445
|
+
/**
|
|
446
|
+
* @method setType
|
|
447
|
+
* @description Changes the body type at runtime (e.g. turning a kinematic
|
|
448
|
+
* moving platform into a dynamic one when it breaks apart). Resets
|
|
449
|
+
* velocities and re-derives mass; existing contacts are dropped so they
|
|
450
|
+
* rebuild against the new type.
|
|
451
|
+
* @param {string | "static" | "dynamic" | "kinematic"} type
|
|
452
|
+
*/
|
|
453
|
+
setType(type: string | "static" | "dynamic" | "kinematic"): void;
|
|
454
|
+
}
|
|
455
|
+
import { Vector2 } from "../Physics.js";
|
|
456
|
+
import Collider from "./Collider.js";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export default Aseprite;
|
|
2
|
+
/**
|
|
3
|
+
* @class Aseprite
|
|
4
|
+
* @description Imports sprite-sheet metadata exported from Aseprite
|
|
5
|
+
* (File ▸ Export Sprite Sheet, with "JSON Data" on) and turns its frame tags
|
|
6
|
+
* into engine animation clips. Works with both the Hash and Array JSON layouts.
|
|
7
|
+
* Pure parsing: pass it the already-parsed JSON object.
|
|
8
|
+
*
|
|
9
|
+
* Assumes the sheet is a uniform grid in frame order (the common case), so the
|
|
10
|
+
* frame indices line up with the engine's Texture/Animator frame numbering.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const cfg = Aseprite.spriteConfig(sheetJson); // {frameWidth, framesPerRow, ...}
|
|
14
|
+
* const tex = new Texture("hero.png", cfg.frameWidth, cfg.frameHeight,
|
|
15
|
+
* cfg.framesPerRow, cfg.totalFrames, 0, false);
|
|
16
|
+
* obj.addComponent(tex);
|
|
17
|
+
* const anim = new Animator();
|
|
18
|
+
* obj.addComponent(anim);
|
|
19
|
+
* Aseprite.applyTo(anim, sheetJson); // registers "idle", "run", ... clips
|
|
20
|
+
* anim.play("run");
|
|
21
|
+
*/
|
|
22
|
+
declare class Aseprite {
|
|
23
|
+
/**
|
|
24
|
+
* @method frames
|
|
25
|
+
* @description Returns the frames as an ordered array regardless of whether
|
|
26
|
+
* the export used the Hash (object) or Array layout.
|
|
27
|
+
* @param {Object} sheet - Parsed Aseprite JSON
|
|
28
|
+
* @returns {Array<Object>}
|
|
29
|
+
*/
|
|
30
|
+
static frames(sheet: any): Array<any>;
|
|
31
|
+
/**
|
|
32
|
+
* @method spriteConfig
|
|
33
|
+
* @description Derives the uniform-grid sprite config (for Texture) from the
|
|
34
|
+
* first frame and the sheet size.
|
|
35
|
+
* @param {Object} sheet - Parsed Aseprite JSON
|
|
36
|
+
* @returns {{frameWidth:number, frameHeight:number, framesPerRow:number, totalFrames:number}}
|
|
37
|
+
*/
|
|
38
|
+
static spriteConfig(sheet: any): {
|
|
39
|
+
frameWidth: number;
|
|
40
|
+
frameHeight: number;
|
|
41
|
+
framesPerRow: number;
|
|
42
|
+
totalFrames: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @method durations
|
|
46
|
+
* @description Per-frame durations in milliseconds, in frame order.
|
|
47
|
+
* @param {Object} sheet - Parsed Aseprite JSON
|
|
48
|
+
* @returns {number[]}
|
|
49
|
+
*/
|
|
50
|
+
static durations(sheet: any): number[];
|
|
51
|
+
/** @private */
|
|
52
|
+
private static _expandTag;
|
|
53
|
+
/**
|
|
54
|
+
* @method toClips
|
|
55
|
+
* @description Builds clip descriptors from the sheet's frame tags. Each clip
|
|
56
|
+
* is `{ name, frames, speed }` where `frames` are frame indices and `speed`
|
|
57
|
+
* is the average frame duration (ms), the per-clip speed the Animator uses.
|
|
58
|
+
* If the sheet has no tags, a single "default" clip spanning all frames is
|
|
59
|
+
* returned.
|
|
60
|
+
* @param {Object} sheet - Parsed Aseprite JSON
|
|
61
|
+
* @returns {Array<{name:string, frames:number[], speed:number}>}
|
|
62
|
+
*/
|
|
63
|
+
static toClips(sheet: any): Array<{
|
|
64
|
+
name: string;
|
|
65
|
+
frames: number[];
|
|
66
|
+
speed: number;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* @method applyTo
|
|
70
|
+
* @description Registers every clip from the sheet on an Animator. Clips loop
|
|
71
|
+
* by default; pass `loop` as a boolean (applies to all) or an object mapping
|
|
72
|
+
* clip name -> boolean to override individual clips.
|
|
73
|
+
* @param {Animator} animator - Target animator
|
|
74
|
+
* @param {Object} sheet - Parsed Aseprite JSON
|
|
75
|
+
* @param {Object} [options] - { loop = true }
|
|
76
|
+
* @returns {Animator} - The animator (for chaining)
|
|
77
|
+
*/
|
|
78
|
+
static applyTo(animator: Animator, sheet: any, options?: any): Animator;
|
|
79
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export default ForgeLevel;
|
|
2
|
+
declare class ForgeLevel {
|
|
3
|
+
/**
|
|
4
|
+
* @method load
|
|
5
|
+
* @description Builds renderable and collidable objects from a Forge export.
|
|
6
|
+
* @param {Object} data - The parsed `level.json`
|
|
7
|
+
* @param {Object} options
|
|
8
|
+
* @param {Scene} options.scene - Scene to add the layer objects to
|
|
9
|
+
* @param {Physics} [options.physics] - Physics engine; omit to skip colliders
|
|
10
|
+
* @param {Object} [options.filter] - Collision filter spec for the colliders
|
|
11
|
+
* @param {Object} [options.ownerObject] - Owner reported by collision events
|
|
12
|
+
* @param {boolean} [options.pixelart=true] - NEAREST filtering for the atlas
|
|
13
|
+
* @param {string} [options.layerOrder="top-first"] - Whether `layers[0]` is
|
|
14
|
+
* the topmost layer ("top-first") or the bottommost ("bottom-first")
|
|
15
|
+
* @returns {Object} - `{ tileSize, cols, rows, width, height, background,
|
|
16
|
+
* bounds, layers, colliders, objects, entityTypes, toWorld }`
|
|
17
|
+
*/
|
|
18
|
+
static load(data: any, options?: {
|
|
19
|
+
scene: Scene;
|
|
20
|
+
physics?: Physics;
|
|
21
|
+
filter?: any;
|
|
22
|
+
ownerObject?: any;
|
|
23
|
+
pixelart?: boolean;
|
|
24
|
+
layerOrder?: string;
|
|
25
|
+
}): any;
|
|
26
|
+
/**
|
|
27
|
+
* @method _readObjects
|
|
28
|
+
* @description Converts one object layer's entries from grid cells to world
|
|
29
|
+
* space. An object's `x`/`y` is its top-left cell and `w`/`h` its size in
|
|
30
|
+
* cells, so a 1x1 object resolves to that cell's centre.
|
|
31
|
+
* @returns {Array<Object>} - `{ type, name, x, y, width, height, props, layer, cell }`
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
private static _readObjects;
|
|
35
|
+
/**
|
|
36
|
+
* @method _buildTileLayer
|
|
37
|
+
* @description Turns one tile layer into an InstancedTexture per tileset it
|
|
38
|
+
* references (a texture switch is a new draw call, so tiles are grouped by
|
|
39
|
+
* the atlas they come from).
|
|
40
|
+
* @returns {Array<Object>} - `{ gameObject, instanced, tileset, layer, count }`
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
private static _buildTileLayer;
|
|
44
|
+
/**
|
|
45
|
+
* @method tileTexCoords
|
|
46
|
+
* @description UV quad for one tile of an atlas, in the corner order
|
|
47
|
+
* `Drawable.getFrameTexCoords` uses: (R,B) (L,B) (R,T) (L,T). Coordinates are
|
|
48
|
+
* inset by half a texel so neighbouring tiles never bleed into each other,
|
|
49
|
+
* and the v axis is flipped because GL samples from the bottom up.
|
|
50
|
+
* @param {Object} tileset - A Forge tileset entry
|
|
51
|
+
* @param {number} index - Tile index within the tileset
|
|
52
|
+
* @param {boolean} [flipH=false]
|
|
53
|
+
* @param {boolean} [flipV=false]
|
|
54
|
+
* @returns {number[]} - 8 UV floats
|
|
55
|
+
*/
|
|
56
|
+
static tileTexCoords(tileset: any, index: number, flipH?: boolean, flipV?: boolean): number[];
|
|
57
|
+
/**
|
|
58
|
+
* @method _tilesetFor
|
|
59
|
+
* @description Finds the tileset that owns a gid (the one with the largest
|
|
60
|
+
* firstgid not greater than it).
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
private static _tilesetFor;
|
|
64
|
+
/**
|
|
65
|
+
* @method _buildColliders
|
|
66
|
+
* @description Creates static bodies for solid tiles. Full-tile colliders are
|
|
67
|
+
* merged into horizontal runs, since BoxCollider is cheaper than a polygon
|
|
68
|
+
* with the same 4 corners. A tile whose collider shape isn't the full tile
|
|
69
|
+
* gets its own {@link PolygonCollider} built from that shape's actual
|
|
70
|
+
* points, in world space, not a bounding-box stand-in.
|
|
71
|
+
* @returns {Array<RigidBody>}
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
private static _buildColliders;
|
|
75
|
+
/**
|
|
76
|
+
* @method _staticBox
|
|
77
|
+
* @description Creates one static body with a box collider, in world pixels.
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
private static _staticBox;
|
|
81
|
+
/**
|
|
82
|
+
* @method _staticPolygon
|
|
83
|
+
* @description Creates one static body with a polygon collider built from a
|
|
84
|
+
* tile's own collider shape. The body sits at the shape's bounding-box
|
|
85
|
+
* centre; the polygon's points are converted from Forge's normalised,
|
|
86
|
+
* top-down tile space into local physics units around that centre.
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
private static _staticPolygon;
|
|
90
|
+
/**
|
|
91
|
+
* @method _boundsOf
|
|
92
|
+
* @description Normalised bounding box of a collider polygon.
|
|
93
|
+
* @returns {{x:number, y:number, w:number, h:number}}
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
private static _boundsOf;
|
|
97
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export default TiledMap;
|
|
2
|
+
export const FLIP_FLAGS: 3758096384;
|
|
3
|
+
export const GID_MASK: 536870911;
|
|
4
|
+
/**
|
|
5
|
+
* @class TiledMap
|
|
6
|
+
* @description Imports orthogonal maps exported from the Tiled editor
|
|
7
|
+
* (https://www.mapeditor.org) in JSON format into the engine's Tilemap, plus
|
|
8
|
+
* helpers to pull object layers (spawn points, triggers, etc.) out as plain
|
|
9
|
+
* data. Pure parsing: pass it the already-parsed JSON object (load it with
|
|
10
|
+
* AssetManager.json or fetch).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const map = TiledMap.toTilemap(mapJson, "tiles.png");
|
|
14
|
+
* scene.add(map.gameObject);
|
|
15
|
+
* map.buildColliders(physics);
|
|
16
|
+
* const spawns = TiledMap.objects(mapJson, { layer: "spawns", flipY: true });
|
|
17
|
+
*/
|
|
18
|
+
declare class TiledMap {
|
|
19
|
+
/**
|
|
20
|
+
* @method tilesetFor
|
|
21
|
+
* @description Finds the tileset a (masked) global id belongs to.
|
|
22
|
+
* @param {Object} map - Parsed Tiled map JSON
|
|
23
|
+
* @param {number} gid - Masked global tile id (flip flags removed)
|
|
24
|
+
* @returns {Object|null}
|
|
25
|
+
*/
|
|
26
|
+
static tilesetFor(map: any, gid: number): any | null;
|
|
27
|
+
/** @private */
|
|
28
|
+
private static _tileLayer;
|
|
29
|
+
/**
|
|
30
|
+
* @method toFrameGrid
|
|
31
|
+
* @description Converts a tile layer into a 2D array of local frame indices
|
|
32
|
+
* (-1 for empty), ready for Tilemap.setMap. Global ids are converted to
|
|
33
|
+
* tileset-local indices and flip flags are stripped.
|
|
34
|
+
* @param {Object} map - Parsed Tiled map JSON
|
|
35
|
+
* @param {Object} [options] - { layer } (name, index, or first tile layer)
|
|
36
|
+
* @returns {number[][]}
|
|
37
|
+
*/
|
|
38
|
+
static toFrameGrid(map: any, options?: any): number[][];
|
|
39
|
+
/**
|
|
40
|
+
* @method toTilemap
|
|
41
|
+
* @description Builds a ready-to-render Tilemap from a Tiled map. The tile
|
|
42
|
+
* sheet config (frame size, columns, count) is read from the map's first
|
|
43
|
+
* tileset; the render tile size comes from the map's tilewidth.
|
|
44
|
+
* @param {Object} map - Parsed Tiled map JSON
|
|
45
|
+
* @param {string} texturePath - Path to the tile sheet image
|
|
46
|
+
* @param {Object} [options] - { layer, pixelart = true, name, originX, originY }
|
|
47
|
+
* @returns {Tilemap}
|
|
48
|
+
*/
|
|
49
|
+
static toTilemap(map: any, texturePath: string, options?: any): Tilemap;
|
|
50
|
+
/**
|
|
51
|
+
* @method objects
|
|
52
|
+
* @description Extracts the objects from an object layer as plain data
|
|
53
|
+
* (spawn points, triggers, regions). Tiled `properties` arrays are flattened
|
|
54
|
+
* into a `props` object. With `flipY` set, y is converted from Tiled's
|
|
55
|
+
* top-left pixel origin to a y-up world using the map's pixel height.
|
|
56
|
+
* @param {Object} map - Parsed Tiled map JSON
|
|
57
|
+
* @param {Object} [options] - { layer, flipY = false, originX = 0, originY = 0 }
|
|
58
|
+
* @returns {Array<Object>}
|
|
59
|
+
*/
|
|
60
|
+
static objects(map: any, options?: any): Array<any>;
|
|
61
|
+
}
|
|
62
|
+
import Tilemap from "../Tilemap.js";
|