melonjs 14.2.0 → 14.3.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/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
- package/dist/melonjs.mjs/_virtual/howler.js +1 -1
- package/dist/melonjs.mjs/_virtual/index.js +1 -1
- package/dist/melonjs.mjs/_virtual/index2.js +1 -1
- package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
- package/dist/melonjs.mjs/application/application.js +153 -9
- package/dist/melonjs.mjs/application/header.js +34 -0
- package/dist/melonjs.mjs/application/resize.js +1 -1
- package/dist/melonjs.mjs/application/settings.js +28 -0
- package/dist/melonjs.mjs/audio/audio.js +1 -1
- package/dist/melonjs.mjs/camera/camera2d.js +2 -2
- package/dist/melonjs.mjs/entity/entity.js +1 -1
- package/dist/melonjs.mjs/game.js +1 -1
- package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
- package/dist/melonjs.mjs/geometries/line.js +1 -1
- package/dist/melonjs.mjs/geometries/path2d.js +1 -1
- package/dist/melonjs.mjs/geometries/point.js +1 -1
- package/dist/melonjs.mjs/geometries/poly.js +1 -1
- package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
- package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
- package/dist/melonjs.mjs/index.js +41 -30
- package/dist/melonjs.mjs/input/gamepad.js +1 -1
- package/dist/melonjs.mjs/input/input.js +1 -1
- package/dist/melonjs.mjs/input/keyboard.js +1 -1
- package/dist/melonjs.mjs/input/pointer.js +2 -2
- package/dist/melonjs.mjs/input/pointerevent.js +2 -2
- package/dist/melonjs.mjs/lang/deprecated.js +1 -1
- package/dist/melonjs.mjs/level/level.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/dist/melonjs.mjs/loader/loader.js +1 -1
- package/dist/melonjs.mjs/loader/loadingscreen.js +2 -2
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/math/color.js +1 -1
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +1 -1
- package/dist/melonjs.mjs/math/matrix3.js +1 -1
- package/dist/melonjs.mjs/math/observable_vector2.js +1 -1
- package/dist/melonjs.mjs/math/observable_vector3.js +1 -1
- package/dist/melonjs.mjs/math/vector2.js +1 -1
- package/dist/melonjs.mjs/math/vector3.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
- package/dist/melonjs.mjs/particles/emitter.js +1 -1
- package/dist/melonjs.mjs/particles/particle.js +1 -1
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +1 -1
- package/dist/melonjs.mjs/physics/bounds.js +1 -1
- package/dist/melonjs.mjs/physics/collision.js +3 -3
- package/dist/melonjs.mjs/physics/detector.js +174 -146
- package/dist/melonjs.mjs/physics/quadtree.js +1 -1
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +1 -1
- package/dist/melonjs.mjs/physics/world.js +10 -30
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +1 -1
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +3 -87
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +2 -2
- package/dist/melonjs.mjs/renderable/light2d.js +1 -1
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
- package/dist/melonjs.mjs/renderable/renderable.js +1 -1
- package/dist/melonjs.mjs/renderable/sprite.js +1 -1
- package/dist/melonjs.mjs/renderable/trigger.js +2 -2
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
- package/dist/melonjs.mjs/state/stage.js +2 -2
- package/dist/melonjs.mjs/state/state.js +2 -2
- package/dist/melonjs.mjs/system/device.js +2 -22
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +1 -1
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +1 -1
- package/dist/melonjs.mjs/system/save.js +1 -1
- package/dist/melonjs.mjs/system/timer.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
- package/dist/melonjs.mjs/text/glyph.js +1 -1
- package/dist/melonjs.mjs/text/text.js +1 -1
- package/dist/melonjs.mjs/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- package/dist/melonjs.mjs/tweens/easing.js +1 -1
- package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
- package/dist/melonjs.mjs/tweens/tween.js +2 -2
- package/dist/melonjs.mjs/utils/agent.js +1 -1
- package/dist/melonjs.mjs/utils/array.js +1 -1
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +1 -1
- package/dist/melonjs.mjs/utils/string.js +1 -1
- package/dist/melonjs.mjs/utils/utils.js +1 -1
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +4 -1
- package/dist/melonjs.mjs/video/renderer.js +8 -1
- package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +3 -2
- package/dist/melonjs.mjs/video/utils/autodetect.js +27 -0
- package/dist/melonjs.mjs/video/utils/resize.js +1 -1
- package/dist/melonjs.mjs/video/video.js +15 -147
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
- package/dist/melonjs.mjs/video/webgl/glshader.js +2 -3
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +20 -2
- package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +4 -1
- package/dist/melonjs.module.js +20922 -20921
- package/dist/types/application/application.d.ts +144 -0
- package/dist/types/application/header.d.ts +5 -0
- package/dist/types/application/resize.d.ts +5 -0
- package/dist/types/application/settings.d.ts +18 -0
- package/dist/types/audio/audio.d.ts +267 -0
- package/dist/types/camera/camera2d.d.ts +289 -0
- package/dist/types/entity/entity.d.ts +98 -0
- package/{src/game.js → dist/types/game.d.ts} +3 -14
- package/dist/types/geometries/ellipse.d.ts +154 -0
- package/dist/types/geometries/line.d.ts +11 -0
- package/dist/types/geometries/path2d.d.ts +121 -0
- package/dist/types/geometries/point.d.ts +53 -0
- package/dist/types/geometries/poly.d.ts +222 -0
- package/dist/types/geometries/rectangle.d.ts +176 -0
- package/dist/types/geometries/roundrect.d.ts +52 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/input/gamepad.d.ts +95 -0
- package/dist/types/input/input.d.ts +15 -0
- package/dist/types/input/keyboard.d.ts +205 -0
- package/dist/types/input/pointer.d.ts +270 -0
- package/dist/types/input/pointerevent.d.ts +181 -0
- package/dist/types/lang/deprecated.d.ts +53 -0
- package/dist/types/level/level.d.ts +134 -0
- package/dist/types/level/tiled/TMXGroup.d.ts +82 -0
- package/dist/types/level/tiled/TMXLayer.d.ts +180 -0
- package/dist/types/level/tiled/TMXObject.d.ts +195 -0
- package/dist/types/level/tiled/TMXTile.d.ts +78 -0
- package/dist/types/level/tiled/TMXTileMap.d.ts +180 -0
- package/dist/types/level/tiled/TMXTileset.d.ts +94 -0
- package/dist/types/level/tiled/TMXTilesetGroup.d.ts +32 -0
- package/dist/types/level/tiled/TMXUtils.d.ts +47 -0
- package/dist/types/level/tiled/renderer/TMXHexagonalRenderer.d.ts +87 -0
- package/dist/types/level/tiled/renderer/TMXIsometricRenderer.d.ts +55 -0
- package/dist/types/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +43 -0
- package/dist/types/level/tiled/renderer/TMXRenderer.d.ts +75 -0
- package/dist/types/level/tiled/renderer/TMXStaggeredRenderer.d.ts +8 -0
- package/dist/types/loader/loader.d.ts +181 -0
- package/dist/types/loader/loadingscreen.d.ts +18 -0
- package/dist/types/math/color.d.ts +170 -0
- package/dist/types/math/math.d.ts +165 -0
- package/dist/types/math/matrix2.d.ts +209 -0
- package/dist/types/math/matrix3.d.ts +236 -0
- package/dist/types/math/observable_vector2.d.ts +278 -0
- package/dist/types/math/observable_vector3.d.ts +277 -0
- package/dist/types/math/vector2.d.ts +327 -0
- package/dist/types/math/vector3.d.ts +332 -0
- package/dist/types/particles/emitter.d.ts +188 -0
- package/dist/types/particles/particle.d.ts +32 -0
- package/dist/types/particles/settings.d.ts +32 -0
- package/dist/types/physics/body.d.ts +330 -0
- package/dist/types/physics/bounds.d.ts +250 -0
- package/dist/types/physics/collision.d.ts +44 -0
- package/dist/types/physics/detector.d.ts +64 -0
- package/dist/types/physics/quadtree.d.ts +79 -0
- package/dist/types/physics/response.d.ts +37 -0
- package/dist/types/physics/sat.d.ts +48 -0
- package/dist/types/physics/world.d.ts +83 -0
- package/dist/types/plugin/plugin.d.ts +10 -0
- package/dist/types/polyfill/console.d.ts +0 -0
- package/dist/types/polyfill/index.d.ts +1 -0
- package/dist/types/polyfill/performance.d.ts +0 -0
- package/dist/types/polyfill/requestAnimationFrame.d.ts +1 -0
- package/dist/types/polyfill/roundrect.d.ts +0 -0
- package/dist/types/renderable/collectable.d.ts +19 -0
- package/dist/types/renderable/colorlayer.d.ts +28 -0
- package/dist/types/renderable/container.d.ts +302 -0
- package/dist/types/renderable/dragndrop.d.ts +118 -0
- package/dist/types/renderable/imagelayer.d.ts +106 -0
- package/dist/types/renderable/light2d.d.ts +58 -0
- package/dist/types/renderable/nineslicesprite.d.ts +59 -0
- package/dist/types/renderable/renderable.d.ts +402 -0
- package/dist/types/renderable/sprite.d.ts +268 -0
- package/dist/types/renderable/trigger.d.ts +61 -0
- package/dist/types/renderable/ui/uibaseelement.d.ts +95 -0
- package/dist/types/renderable/ui/uispriteelement.d.ts +127 -0
- package/dist/types/renderable/ui/uitextbutton.d.ts +54 -0
- package/dist/types/state/stage.d.ts +116 -0
- package/dist/types/state/state.d.ts +170 -0
- package/dist/types/system/device.d.ts +579 -0
- package/dist/types/system/dom.d.ts +1 -0
- package/dist/types/system/event.d.ts +473 -0
- package/dist/types/system/platform.d.ts +31 -0
- package/dist/types/system/pooling.d.ts +101 -0
- package/dist/types/system/save.d.ts +25 -0
- package/dist/types/system/timer.d.ts +126 -0
- package/dist/types/text/bitmaptext.d.ts +151 -0
- package/dist/types/text/bitmaptextdata.d.ts +35 -0
- package/dist/types/text/glyph.d.ts +28 -0
- package/dist/types/text/text.d.ts +173 -0
- package/dist/types/text/textmetrics.d.ts +47 -0
- package/dist/types/text/textstyle.d.ts +5 -0
- package/dist/types/tweens/easing.d.ts +46 -0
- package/dist/types/tweens/interpolation.d.ts +18 -0
- package/dist/types/tweens/tween.d.ts +195 -0
- package/dist/types/utils/agent.d.ts +21 -0
- package/dist/types/utils/array.d.ts +39 -0
- package/dist/types/utils/file.d.ts +18 -0
- package/dist/types/utils/function.d.ts +32 -0
- package/dist/types/utils/string.d.ts +50 -0
- package/dist/types/utils/utils.d.ts +17 -0
- package/dist/types/video/canvas/canvas_renderer.d.ts +380 -0
- package/dist/types/video/renderer.d.ts +222 -0
- package/dist/types/video/texture/atlas.d.ts +201 -0
- package/dist/types/video/texture/cache.d.ts +45 -0
- package/dist/types/video/texture/canvas_texture.d.ts +78 -0
- package/dist/types/video/utils/autodetect.d.ts +7 -0
- package/dist/types/video/utils/resize.d.ts +4 -0
- package/dist/types/video/video.d.ts +92 -0
- package/dist/types/video/webgl/buffer/vertex.d.ts +56 -0
- package/dist/types/video/webgl/glshader.d.ts +93 -0
- package/dist/types/video/webgl/utils/attributes.d.ts +4 -0
- package/dist/types/video/webgl/utils/precision.d.ts +13 -0
- package/dist/types/video/webgl/utils/program.d.ts +5 -0
- package/dist/types/video/webgl/utils/string.d.ts +5 -0
- package/dist/types/video/webgl/utils/uniforms.d.ts +4 -0
- package/dist/types/video/webgl/webgl_compositor.d.ts +174 -0
- package/dist/types/video/webgl/webgl_renderer.d.ts +429 -0
- package/package.json +4 -4
- package/src/application/application.js +151 -7
- package/src/application/header.js +25 -0
- package/src/{video/utils → application}/resize.js +9 -6
- package/src/application/settings.js +19 -0
- package/src/camera/camera2d.js +1 -1
- package/src/index.js +34 -23
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +1 -1
- package/src/level/level.js +1 -1
- package/src/level/tiled/TMXLayer.js +1 -1
- package/src/level/tiled/TMXTileMap.js +2 -2
- package/src/loader/loadingscreen.js +1 -1
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +172 -145
- package/src/physics/world.js +10 -30
- package/src/renderable/container.js +7 -91
- package/src/renderable/imagelayer.js +1 -1
- package/src/renderable/trigger.js +1 -1
- package/src/renderable/ui/uibaseelement.js +1 -1
- package/src/state/stage.js +1 -1
- package/src/state/state.js +1 -1
- package/src/system/device.js +0 -20
- package/src/tweens/tween.js +1 -1
- package/src/video/canvas/canvas_renderer.js +3 -0
- package/src/video/renderer.js +7 -0
- package/src/video/texture/canvas_texture.js +2 -1
- package/src/video/utils/autodetect.js +18 -0
- package/src/video/video.js +13 -145
- package/src/video/webgl/glshader.js +3 -4
- package/src/video/webgl/utils/precision.js +18 -0
- package/src/video/webgl/webgl_renderer.js +3 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a bound object contains methods for creating and manipulating axis-aligned bounding boxes (AABB).
|
|
4
|
+
*/
|
|
5
|
+
export default class Bounds {
|
|
6
|
+
/**
|
|
7
|
+
* @param {Vector2d[]} [vertices] - an array of me.Vector2d points
|
|
8
|
+
*/
|
|
9
|
+
constructor(vertices?: Vector2d[] | undefined);
|
|
10
|
+
_center: Vector2d;
|
|
11
|
+
/**
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
onResetEvent(vertices: any): void;
|
|
15
|
+
min: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
} | undefined;
|
|
19
|
+
max: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
} | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* reset the bound
|
|
25
|
+
* @name clear
|
|
26
|
+
* @memberof Bounds
|
|
27
|
+
*/
|
|
28
|
+
clear(): void;
|
|
29
|
+
/**
|
|
30
|
+
* sets the bounds to the given min and max value
|
|
31
|
+
* @name setMinMax
|
|
32
|
+
* @memberof Bounds
|
|
33
|
+
* @param {number} minX
|
|
34
|
+
* @param {number} minY
|
|
35
|
+
* @param {number} maxX
|
|
36
|
+
* @param {number} maxY
|
|
37
|
+
*/
|
|
38
|
+
setMinMax(minX: number, minY: number, maxX: number, maxY: number): void;
|
|
39
|
+
public set x(arg: number);
|
|
40
|
+
/**
|
|
41
|
+
* x position of the bound
|
|
42
|
+
* @public
|
|
43
|
+
* @type {number}
|
|
44
|
+
* @name x
|
|
45
|
+
* @memberof Bounds
|
|
46
|
+
*/
|
|
47
|
+
public get x(): number;
|
|
48
|
+
public set y(arg: number);
|
|
49
|
+
/**
|
|
50
|
+
* y position of the bounds
|
|
51
|
+
* @public
|
|
52
|
+
* @type {number}
|
|
53
|
+
* @name y
|
|
54
|
+
* @memberof Bounds
|
|
55
|
+
*/
|
|
56
|
+
public get y(): number;
|
|
57
|
+
public set width(arg: number);
|
|
58
|
+
/**
|
|
59
|
+
* width of the bounds
|
|
60
|
+
* @public
|
|
61
|
+
* @type {number}
|
|
62
|
+
* @name width
|
|
63
|
+
* @memberof Bounds
|
|
64
|
+
*/
|
|
65
|
+
public get width(): number;
|
|
66
|
+
public set height(arg: number);
|
|
67
|
+
/**
|
|
68
|
+
* width of the bounds
|
|
69
|
+
* @public
|
|
70
|
+
* @type {number}
|
|
71
|
+
* @name width
|
|
72
|
+
* @memberof Bounds
|
|
73
|
+
*/
|
|
74
|
+
public get height(): number;
|
|
75
|
+
/**
|
|
76
|
+
* left coordinate of the bound
|
|
77
|
+
* @public
|
|
78
|
+
* @type {number}
|
|
79
|
+
* @name left
|
|
80
|
+
* @memberof Bounds
|
|
81
|
+
*/
|
|
82
|
+
public get left(): number;
|
|
83
|
+
/**
|
|
84
|
+
* right coordinate of the bound
|
|
85
|
+
* @public
|
|
86
|
+
* @type {number}
|
|
87
|
+
* @name right
|
|
88
|
+
* @memberof Bounds
|
|
89
|
+
*/
|
|
90
|
+
public get right(): number;
|
|
91
|
+
/**
|
|
92
|
+
* top coordinate of the bound
|
|
93
|
+
* @public
|
|
94
|
+
* @type {number}
|
|
95
|
+
* @name top
|
|
96
|
+
* @memberof Bounds
|
|
97
|
+
*/
|
|
98
|
+
public get top(): number;
|
|
99
|
+
/**
|
|
100
|
+
* bottom coordinate of the bound
|
|
101
|
+
* @public
|
|
102
|
+
* @type {number}
|
|
103
|
+
* @name bottom
|
|
104
|
+
* @memberof Bounds
|
|
105
|
+
*/
|
|
106
|
+
public get bottom(): number;
|
|
107
|
+
/**
|
|
108
|
+
* center position of the bound on the x axis
|
|
109
|
+
* @public
|
|
110
|
+
* @type {number}
|
|
111
|
+
* @name centerX
|
|
112
|
+
* @memberof Bounds
|
|
113
|
+
*/
|
|
114
|
+
public get centerX(): number;
|
|
115
|
+
/**
|
|
116
|
+
* center position of the bound on the y axis
|
|
117
|
+
* @public
|
|
118
|
+
* @type {number}
|
|
119
|
+
* @name centerY
|
|
120
|
+
* @memberof Bounds
|
|
121
|
+
*/
|
|
122
|
+
public get centerY(): number;
|
|
123
|
+
/**
|
|
124
|
+
* return the center position of the bound
|
|
125
|
+
* @public
|
|
126
|
+
* @type {Vector2d}
|
|
127
|
+
* @name center
|
|
128
|
+
* @memberof Bounds
|
|
129
|
+
*/
|
|
130
|
+
public get center(): Vector2d;
|
|
131
|
+
/**
|
|
132
|
+
* Updates bounds using the given vertices
|
|
133
|
+
* @name update
|
|
134
|
+
* @memberof Bounds
|
|
135
|
+
* @param {Vector2d[]} vertices - an array of me.Vector2d points
|
|
136
|
+
*/
|
|
137
|
+
update(vertices: Vector2d[]): void;
|
|
138
|
+
/**
|
|
139
|
+
* add the given vertices to the bounds definition.
|
|
140
|
+
* @name add
|
|
141
|
+
* @memberof Bounds
|
|
142
|
+
* @param {Vector2d[]} vertices - an array of me.Vector2d points
|
|
143
|
+
* @param {boolean} [clear=false] - either to reset the bounds before adding the new vertices
|
|
144
|
+
*/
|
|
145
|
+
add(vertices: Vector2d[], clear?: boolean | undefined): void;
|
|
146
|
+
/**
|
|
147
|
+
* add the given bounds to the bounds definition.
|
|
148
|
+
* @name addBounds
|
|
149
|
+
* @memberof Bounds
|
|
150
|
+
* @param {Bounds} bounds
|
|
151
|
+
* @param {boolean} [clear=false] - either to reset the bounds before adding the new vertices
|
|
152
|
+
*/
|
|
153
|
+
addBounds(bounds: Bounds, clear?: boolean | undefined): void;
|
|
154
|
+
/**
|
|
155
|
+
* add the given point to the bounds definition.
|
|
156
|
+
* @name addPoint
|
|
157
|
+
* @memberof Bounds
|
|
158
|
+
* @param {Vector2d|Point} point - the point to be added to the bounds
|
|
159
|
+
* @param {Matrix2d} [m] - an optional transform to apply to the given point (only if the given point is a vector)
|
|
160
|
+
*/
|
|
161
|
+
addPoint(point: Vector2d | Point, m?: any): void;
|
|
162
|
+
/**
|
|
163
|
+
* add the given quad coordinates to this bound definition, multiplied by the given matrix
|
|
164
|
+
* @name addFrame
|
|
165
|
+
* @memberof Bounds
|
|
166
|
+
* @param {number} x0 - left X coordinates of the quad
|
|
167
|
+
* @param {number} y0 - top Y coordinates of the quad
|
|
168
|
+
* @param {number} x1 - right X coordinates of the quad
|
|
169
|
+
* @param {number} y1 - bottom y coordinates of the quad
|
|
170
|
+
* @param {Matrix2d} [m] - an optional transform to apply to the given frame coordinates
|
|
171
|
+
*/
|
|
172
|
+
addFrame(x0: number, y0: number, x1: number, y1: number, m?: any): void;
|
|
173
|
+
/**
|
|
174
|
+
* Returns true if the bounds contains the given point.
|
|
175
|
+
* @name contains
|
|
176
|
+
* @memberof Bounds
|
|
177
|
+
* @method
|
|
178
|
+
* @param {Vector2d} point
|
|
179
|
+
* @returns {boolean} True if the bounds contain the point, otherwise false
|
|
180
|
+
*/
|
|
181
|
+
/**
|
|
182
|
+
* Returns true if the bounds contains the given point.
|
|
183
|
+
* @name contains
|
|
184
|
+
* @memberof Bounds
|
|
185
|
+
* @param {number} x
|
|
186
|
+
* @param {number} y
|
|
187
|
+
* @returns {boolean} True if the bounds contain the point, otherwise false
|
|
188
|
+
*/
|
|
189
|
+
contains(...args: any[]): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Returns true if the two bounds intersect.
|
|
192
|
+
* @name overlaps
|
|
193
|
+
* @memberof Bounds
|
|
194
|
+
* @param {Bounds|Rect} bounds
|
|
195
|
+
* @returns {boolean} True if the bounds overlap, otherwise false
|
|
196
|
+
*/
|
|
197
|
+
overlaps(bounds: Bounds | Rect): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* determines whether all coordinates of this bounds are finite numbers.
|
|
200
|
+
* @name isFinite
|
|
201
|
+
* @memberof Bounds
|
|
202
|
+
* @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
|
|
203
|
+
*/
|
|
204
|
+
isFinite(): boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Translates the bounds by the given vector.
|
|
207
|
+
* @name translate
|
|
208
|
+
* @memberof Bounds
|
|
209
|
+
* @method
|
|
210
|
+
* @param {Vector2d} vector
|
|
211
|
+
*/
|
|
212
|
+
/**
|
|
213
|
+
* Translates the bounds by x on the x axis, and y on the y axis
|
|
214
|
+
* @name translate
|
|
215
|
+
* @memberof Bounds
|
|
216
|
+
* @param {number} x
|
|
217
|
+
* @param {number} y
|
|
218
|
+
*/
|
|
219
|
+
translate(...args: any[]): void;
|
|
220
|
+
/**
|
|
221
|
+
* Shifts the bounds to the given position vector.
|
|
222
|
+
* @name shift
|
|
223
|
+
* @memberof Bounds
|
|
224
|
+
* @method
|
|
225
|
+
* @param {Vector2d} position
|
|
226
|
+
*/
|
|
227
|
+
/**
|
|
228
|
+
* Shifts the bounds to the given x, y position.
|
|
229
|
+
* @name shift
|
|
230
|
+
* @memberof Bounds
|
|
231
|
+
* @param {number} x
|
|
232
|
+
* @param {number} y
|
|
233
|
+
*/
|
|
234
|
+
shift(...args: any[]): void;
|
|
235
|
+
/**
|
|
236
|
+
* clone this bounds
|
|
237
|
+
* @name clone
|
|
238
|
+
* @memberof Bounds
|
|
239
|
+
* @returns {Bounds}
|
|
240
|
+
*/
|
|
241
|
+
clone(): Bounds;
|
|
242
|
+
/**
|
|
243
|
+
* Returns a polygon whose edges are the same as this bounds.
|
|
244
|
+
* @name toPolygon
|
|
245
|
+
* @memberof Bounds
|
|
246
|
+
* @returns {Polygon} a new Polygon that represents this bounds.
|
|
247
|
+
*/
|
|
248
|
+
toPolygon(): Polygon;
|
|
249
|
+
}
|
|
250
|
+
import Vector2d from "./../math/vector2.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default collision;
|
|
2
|
+
declare namespace collision {
|
|
3
|
+
const maxChildren: number;
|
|
4
|
+
const maxDepth: number;
|
|
5
|
+
namespace types {
|
|
6
|
+
const NO_OBJECT: number;
|
|
7
|
+
const PLAYER_OBJECT: number;
|
|
8
|
+
const NPC_OBJECT: number;
|
|
9
|
+
const ENEMY_OBJECT: number;
|
|
10
|
+
const COLLECTABLE_OBJECT: number;
|
|
11
|
+
const ACTION_OBJECT: number;
|
|
12
|
+
const PROJECTILE_OBJECT: number;
|
|
13
|
+
const WORLD_SHAPE: number;
|
|
14
|
+
const USER: number;
|
|
15
|
+
const ALL_OBJECT: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Checks for object colliding with the given line
|
|
19
|
+
* @name rayCast
|
|
20
|
+
* @memberof collision
|
|
21
|
+
* @public
|
|
22
|
+
* @param {Line} line - line to be tested for collision
|
|
23
|
+
* @param {Array.<Renderable>} [result] - a user defined array that will be populated with intersecting physic objects.
|
|
24
|
+
* @returns {Array.<Renderable>} an array of intersecting physic objects
|
|
25
|
+
* @example
|
|
26
|
+
* // define a line accross the viewport
|
|
27
|
+
* var ray = new me.Line(
|
|
28
|
+
* // absolute position of the line
|
|
29
|
+
* 0, 0, [
|
|
30
|
+
* // starting point relative to the initial position
|
|
31
|
+
* new me.Vector2d(0, 0),
|
|
32
|
+
* // ending point
|
|
33
|
+
* new me.Vector2d(me.game.viewport.width, me.game.viewport.height)
|
|
34
|
+
* ]);
|
|
35
|
+
*
|
|
36
|
+
* // check for collition
|
|
37
|
+
* result = me.collision.rayCast(ray);
|
|
38
|
+
*
|
|
39
|
+
* if (result.length > 0) {
|
|
40
|
+
* // ...
|
|
41
|
+
* }
|
|
42
|
+
*/
|
|
43
|
+
function rayCast(line: Line, result?: Renderable[] | undefined): Renderable[];
|
|
44
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* the Detector class contains methods for detecting collisions between bodies using a broadphase algorithm.
|
|
3
|
+
*/
|
|
4
|
+
export default class Detector {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Container} world - the physic world this detector is bind to
|
|
7
|
+
*/
|
|
8
|
+
constructor(world: Container);
|
|
9
|
+
world: Container;
|
|
10
|
+
/**
|
|
11
|
+
* the default response object used for collisions
|
|
12
|
+
* (will be automatically populated by the collides functions)
|
|
13
|
+
* @type {ResponseObject}
|
|
14
|
+
*/
|
|
15
|
+
response: ResponseObject;
|
|
16
|
+
/**
|
|
17
|
+
* determine if two objects should collide (based on both respective objects body collision mask and type).<br>
|
|
18
|
+
* you can redefine this function if you need any specific rules over what should collide with what.
|
|
19
|
+
* @param {Renderable} a - a reference to the object A.
|
|
20
|
+
* @param {Renderable} b - a reference to the object B.
|
|
21
|
+
* @returns {boolean} true if they should collide, false otherwise
|
|
22
|
+
*/
|
|
23
|
+
shouldCollide(a: Renderable, b: Renderable): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* detect collision between two bodies.
|
|
26
|
+
* @param {Body} bodyA - a reference to body A.
|
|
27
|
+
* @param {Body} bodyB - a reference to body B.
|
|
28
|
+
* @returns {Boolean} true if colliding
|
|
29
|
+
*/
|
|
30
|
+
collides(bodyA: Body, bodyB: Body, response?: ResponseObject): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* find all the collisions for the specified object using a broadphase algorithm
|
|
33
|
+
* @ignore
|
|
34
|
+
* @param {Renderable} objA - object to be tested for collision
|
|
35
|
+
* @returns {boolean} in case of collision, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
collisions(objA: Renderable): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Checks for object colliding with the given line
|
|
40
|
+
* @ignore
|
|
41
|
+
* @param {Line} line - line to be tested for collision
|
|
42
|
+
* @param {Array.<Renderable>} [result] - a user defined array that will be populated with intersecting physic objects.
|
|
43
|
+
* @returns {Array.<Renderable>} an array of intersecting physic objects
|
|
44
|
+
* @example
|
|
45
|
+
* // define a line accross the viewport
|
|
46
|
+
* var ray = new me.Line(
|
|
47
|
+
* // absolute position of the line
|
|
48
|
+
* 0, 0, [
|
|
49
|
+
* // starting point relative to the initial position
|
|
50
|
+
* new me.Vector2d(0, 0),
|
|
51
|
+
* // ending point
|
|
52
|
+
* new me.Vector2d(me.game.viewport.width, me.game.viewport.height)
|
|
53
|
+
* ]);
|
|
54
|
+
*
|
|
55
|
+
* // check for collition
|
|
56
|
+
* result = me.collision.rayCast(ray);
|
|
57
|
+
*
|
|
58
|
+
* if (result.length > 0) {
|
|
59
|
+
* // ...
|
|
60
|
+
* }
|
|
61
|
+
*/
|
|
62
|
+
rayCast(line: Line, result?: Renderable[] | undefined): Array<Renderable>;
|
|
63
|
+
}
|
|
64
|
+
import ResponseObject from "./response.js";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a QuadTree implementation in JavaScript, a 2d spatial subdivision algorithm.
|
|
4
|
+
* @see game.world.broadphase
|
|
5
|
+
*/
|
|
6
|
+
export default class QuadTree {
|
|
7
|
+
/**
|
|
8
|
+
* @param {World} world - the physic world this QuadTree belongs to
|
|
9
|
+
* @param {Bounds} bounds - bounds of the node
|
|
10
|
+
* @param {number} [max_objects=4] - max objects a node can hold before splitting into 4 subnodes
|
|
11
|
+
* @param {number} [max_levels=4] - total max levels inside root Quadtree
|
|
12
|
+
* @param {number} [level] - deepth level, required for subnodes
|
|
13
|
+
*/
|
|
14
|
+
constructor(world: World, bounds: Bounds, max_objects?: number | undefined, max_levels?: number | undefined, level?: number | undefined);
|
|
15
|
+
world: World;
|
|
16
|
+
bounds: Bounds;
|
|
17
|
+
max_objects: number;
|
|
18
|
+
max_levels: number;
|
|
19
|
+
level: number;
|
|
20
|
+
objects: any[];
|
|
21
|
+
nodes: any[];
|
|
22
|
+
split(): void;
|
|
23
|
+
getIndex(item: any): number;
|
|
24
|
+
/**
|
|
25
|
+
* Insert the given object container into the node.
|
|
26
|
+
* @name insertContainer
|
|
27
|
+
* @memberof QuadTree
|
|
28
|
+
* @param {Container} container - group of objects to be added
|
|
29
|
+
*/
|
|
30
|
+
insertContainer(container: Container): void;
|
|
31
|
+
/**
|
|
32
|
+
* Insert the given object into the node. If the node
|
|
33
|
+
* exceeds the capacity, it will split and add all
|
|
34
|
+
* objects to their corresponding subnodes.
|
|
35
|
+
* @name insert
|
|
36
|
+
* @memberof QuadTree
|
|
37
|
+
* @param {object} item - object to be added
|
|
38
|
+
*/
|
|
39
|
+
insert(item: object): void;
|
|
40
|
+
/**
|
|
41
|
+
* Return all objects that could collide with the given object
|
|
42
|
+
* @name retrieve
|
|
43
|
+
* @memberof QuadTree
|
|
44
|
+
* @param {object} item - object to be checked against
|
|
45
|
+
* @param {object} [fn] - a sorting function for the returned array
|
|
46
|
+
* @returns {object[]} array with all detected objects
|
|
47
|
+
*/
|
|
48
|
+
retrieve(item: object, fn?: object | undefined): object[];
|
|
49
|
+
/**
|
|
50
|
+
* Remove the given item from the quadtree.
|
|
51
|
+
* (this function won't recalculate the impacted node)
|
|
52
|
+
* @name remove
|
|
53
|
+
* @memberof QuadTree
|
|
54
|
+
* @param {object} item - object to be removed
|
|
55
|
+
* @returns {boolean} true if the item was found and removed.
|
|
56
|
+
*/
|
|
57
|
+
remove(item: object): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* return true if the node is prunable
|
|
60
|
+
* @name isPrunable
|
|
61
|
+
* @memberof QuadTree
|
|
62
|
+
* @returns {boolean} true if the node is prunable
|
|
63
|
+
*/
|
|
64
|
+
isPrunable(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* return true if the node has any children
|
|
67
|
+
* @name hasChildren
|
|
68
|
+
* @memberof QuadTree
|
|
69
|
+
* @returns {boolean} true if the node has any children
|
|
70
|
+
*/
|
|
71
|
+
hasChildren(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* clear the quadtree
|
|
74
|
+
* @name clear
|
|
75
|
+
* @memberof QuadTree
|
|
76
|
+
* @param {Bounds} [bounds=this.bounds] - the bounds to be cleared
|
|
77
|
+
*/
|
|
78
|
+
clear(bounds?: any): void;
|
|
79
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* An object representing the result of an intersection.
|
|
4
|
+
* @property {Renderable} a The first object participating in the intersection
|
|
5
|
+
* @property {Renderable} b The second object participating in the intersection
|
|
6
|
+
* @property {number} overlap Magnitude of the overlap on the shortest colliding axis
|
|
7
|
+
* @property {Vector2d} overlapV The overlap vector (i.e. `overlapN.scale(overlap, overlap)`). If this vector is subtracted from the position of a, a and b will no longer be colliding
|
|
8
|
+
* @property {Vector2d} overlapN The shortest colliding axis (unit-vector)
|
|
9
|
+
* @property {boolean} aInB Whether the first object is entirely inside the second
|
|
10
|
+
* @property {boolean} bInA Whether the second object is entirely inside the first
|
|
11
|
+
* @property {number} indexShapeA The index of the colliding shape for the object a body
|
|
12
|
+
* @property {number} indexShapeB The index of the colliding shape for the object b body
|
|
13
|
+
* @name ResponseObject
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export default class ResponseObject {
|
|
17
|
+
a: any;
|
|
18
|
+
b: any;
|
|
19
|
+
overlapN: Vector2d;
|
|
20
|
+
overlapV: Vector2d;
|
|
21
|
+
aInB: boolean;
|
|
22
|
+
bInA: boolean;
|
|
23
|
+
indexShapeA: number;
|
|
24
|
+
indexShapeB: number;
|
|
25
|
+
overlap: number;
|
|
26
|
+
/**
|
|
27
|
+
* Set some values of the response back to their defaults. <br>
|
|
28
|
+
* Call this between tests if you are going to reuse a single <br>
|
|
29
|
+
* Response object for multiple intersection tests <br>
|
|
30
|
+
* (recommended as it will avoid allocating extra memory) <br>
|
|
31
|
+
* @name clear
|
|
32
|
+
* @public
|
|
33
|
+
* @returns {object} this object for chaining
|
|
34
|
+
*/
|
|
35
|
+
public clear(): object;
|
|
36
|
+
}
|
|
37
|
+
import Vector2d from "./../math/vector2.js";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether polygons collide.
|
|
3
|
+
* @ignore
|
|
4
|
+
* @param {Renderable} a - a reference to the object A.
|
|
5
|
+
* @param {Polygon} polyA - a reference to the object A Polygon to be tested
|
|
6
|
+
* @param {Renderable} b - a reference to the object B.
|
|
7
|
+
* @param {Polygon} polyB - a reference to the object B Polygon to be tested
|
|
8
|
+
* @param {Response=} response - Response object (optional) that will be populated if they intersect.
|
|
9
|
+
* @returns {boolean} true if they intersect, false if they don't.
|
|
10
|
+
*/
|
|
11
|
+
export function testPolygonPolygon(a: Renderable, polyA: Polygon, b: Renderable, polyB: Polygon, response?: Response | undefined): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Check if two Ellipse collide.
|
|
14
|
+
* @ignore
|
|
15
|
+
* @param {Renderable} a - a reference to the object A.
|
|
16
|
+
* @param {Ellipse} ellipseA - a reference to the object A Ellipse to be tested
|
|
17
|
+
* @param {Renderable} b - a reference to the object B.
|
|
18
|
+
* @param {Ellipse} ellipseB - a reference to the object B Ellipse to be tested
|
|
19
|
+
* @param {Response=} response - Response object (optional) that will be populated if
|
|
20
|
+
* the circles intersect.
|
|
21
|
+
* @returns {boolean} true if the circles intersect, false if they don't.
|
|
22
|
+
*/
|
|
23
|
+
export function testEllipseEllipse(a: Renderable, ellipseA: Ellipse, b: Renderable, ellipseB: Ellipse, response?: Response | undefined): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a polygon and an ellipse collide.
|
|
26
|
+
* @ignore
|
|
27
|
+
* @param {Renderable} a - a reference to the object A.
|
|
28
|
+
* @param {Polygon} polyA - a reference to the object A Polygon to be tested
|
|
29
|
+
* @param {Renderable} b - a reference to the object B.
|
|
30
|
+
* @param {Ellipse} ellipseB - a reference to the object B Ellipse to be tested
|
|
31
|
+
* @param {Response=} response - Response object (optional) that will be populated if they intersect.
|
|
32
|
+
* @returns {boolean} true if they intersect, false if they don't.
|
|
33
|
+
*/
|
|
34
|
+
export function testPolygonEllipse(a: Renderable, polyA: Polygon, b: Renderable, ellipseB: Ellipse, response?: Response | undefined): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Check if an ellipse and a polygon collide. <br>
|
|
37
|
+
* **NOTE:** This is slightly less efficient than testPolygonEllipse as it just
|
|
38
|
+
* runs testPolygonEllipse and reverses the response at the end.
|
|
39
|
+
* @ignore
|
|
40
|
+
* @param {Renderable} a - a reference to the object A.
|
|
41
|
+
* @param {Ellipse} ellipseA - a reference to the object A Ellipse to be tested
|
|
42
|
+
* @param {Renderable} b - a reference to the object B.
|
|
43
|
+
* @param {Polygon} polyB - a reference to the object B Polygon to be tested
|
|
44
|
+
* @param {Response=} response - Response object (optional) that will be populated if
|
|
45
|
+
* they intersect.
|
|
46
|
+
* @returns {boolean} true if they intersect, false if they don't.
|
|
47
|
+
*/
|
|
48
|
+
export function testEllipsePolygon(a: Renderable, ellipseA: Ellipse, b: Renderable, polyB: Polygon, response?: Response | undefined): boolean;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* an object representing the physic world, and responsible for managing and updating all childs and physics
|
|
4
|
+
* @augments Container
|
|
5
|
+
*/
|
|
6
|
+
export default class World extends Container {
|
|
7
|
+
/**
|
|
8
|
+
* @param {number} [x=0] - position of the container (accessible via the inherited pos.x property)
|
|
9
|
+
* @param {number} [y=0] - position of the container (accessible via the inherited pos.y property)
|
|
10
|
+
* @param {number} [width=game.viewport.width] - width of the container
|
|
11
|
+
* @param {number} [height=game.viewport.height] - height of the container
|
|
12
|
+
*/
|
|
13
|
+
constructor(x?: number | undefined, y?: number | undefined, width?: number | undefined, height?: number | undefined);
|
|
14
|
+
/**
|
|
15
|
+
* the application (game) this physic world belong to
|
|
16
|
+
* @type {Application}
|
|
17
|
+
*/
|
|
18
|
+
app: Application;
|
|
19
|
+
/**
|
|
20
|
+
* the rate at which the game world is updated,
|
|
21
|
+
* may be greater than or lower than the display fps
|
|
22
|
+
* @default 60
|
|
23
|
+
* @see timer.maxfps
|
|
24
|
+
*/
|
|
25
|
+
fps: number;
|
|
26
|
+
/**
|
|
27
|
+
* world gravity
|
|
28
|
+
* @type {Vector2d}
|
|
29
|
+
* @default <0,0.98>
|
|
30
|
+
*/
|
|
31
|
+
gravity: Vector2d;
|
|
32
|
+
/**
|
|
33
|
+
* Specify the rendering method for tile layers. <br>
|
|
34
|
+
* if false visible part of the layers are rendered dynamically,<br>
|
|
35
|
+
* if true the entire layers are first rendered into an offscreen canvas.<br>
|
|
36
|
+
* the "best" rendering method depends of your game
|
|
37
|
+
* (amount of layer, layer size, amount of tiles per layer, etc.)<br>
|
|
38
|
+
* note : rendering method is also configurable per layer by adding this
|
|
39
|
+
* property to your layer (in Tiled).
|
|
40
|
+
* @type {boolean}
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
preRender: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* the active physic bodies in this simulation
|
|
46
|
+
* @type {Set<Body>}
|
|
47
|
+
*/
|
|
48
|
+
bodies: Set<Body>;
|
|
49
|
+
/**
|
|
50
|
+
* the instance of the game world quadtree used for broadphase
|
|
51
|
+
* @type {QuadTree}
|
|
52
|
+
*/
|
|
53
|
+
broadphase: QuadTree;
|
|
54
|
+
/**
|
|
55
|
+
* the collision detector instance used by this world instance
|
|
56
|
+
* @type {Detector}
|
|
57
|
+
*/
|
|
58
|
+
detector: Detector;
|
|
59
|
+
/**
|
|
60
|
+
* Add a physic body to the game world
|
|
61
|
+
* @see Container.addChild
|
|
62
|
+
* @param {Body} body
|
|
63
|
+
* @returns {World} this game world
|
|
64
|
+
*/
|
|
65
|
+
addBody(body: Body): World;
|
|
66
|
+
/**
|
|
67
|
+
* Remove a physic body from the game world
|
|
68
|
+
* @see Container.removeChild
|
|
69
|
+
* @param {Body} body
|
|
70
|
+
* @returns {World} this game world
|
|
71
|
+
*/
|
|
72
|
+
removeBody(body: Body): World;
|
|
73
|
+
/**
|
|
74
|
+
* Apply gravity to the given body
|
|
75
|
+
* @private
|
|
76
|
+
* @param {Body} body
|
|
77
|
+
*/
|
|
78
|
+
private bodyApplyGravity;
|
|
79
|
+
}
|
|
80
|
+
import Container from "../renderable/container.js";
|
|
81
|
+
import Vector2d from "./../math/vector2.js";
|
|
82
|
+
import QuadTree from "./quadtree.js";
|
|
83
|
+
import Detector from "./detector.js";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a basic collectable helper class for immovable object (e.g. a coin)
|
|
4
|
+
* @augments Sprite
|
|
5
|
+
*/
|
|
6
|
+
export default class Collectable extends Sprite {
|
|
7
|
+
/**
|
|
8
|
+
* @param {number} x - the x coordinates of the collectable
|
|
9
|
+
* @param {number} y - the y coordinates of the collectable
|
|
10
|
+
* @param {object} settings - See {@link Sprite}
|
|
11
|
+
*/
|
|
12
|
+
constructor(x: number, y: number, settings: object);
|
|
13
|
+
name: any;
|
|
14
|
+
type: any;
|
|
15
|
+
id: any;
|
|
16
|
+
body: Body;
|
|
17
|
+
}
|
|
18
|
+
import Sprite from "./sprite.js";
|
|
19
|
+
import Body from "./../physics/body.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a generic Color Layer Object. Fills the entire Canvas with the color not just the container the object belongs to.
|
|
4
|
+
* @augments Renderable
|
|
5
|
+
*/
|
|
6
|
+
export default class ColorLayer extends Renderable {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} name - Layer name
|
|
9
|
+
* @param {Color|string} color - CSS color
|
|
10
|
+
* @param {number} [z = 0] - z-index position
|
|
11
|
+
*/
|
|
12
|
+
constructor(name: string, color: Color | string, z?: number | undefined);
|
|
13
|
+
/**
|
|
14
|
+
* the layer color component
|
|
15
|
+
* @public
|
|
16
|
+
* @type {Color}
|
|
17
|
+
* @name color
|
|
18
|
+
* @memberof ColorLayer#
|
|
19
|
+
*/
|
|
20
|
+
public color: Color;
|
|
21
|
+
onResetEvent(name: any, color: any, z?: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Destroy function
|
|
24
|
+
* @ignore
|
|
25
|
+
*/
|
|
26
|
+
destroy(): void;
|
|
27
|
+
}
|
|
28
|
+
import Renderable from "./renderable.js";
|