melonjs 14.2.0 → 14.4.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 +2 -2
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +2 -2
- package/dist/melonjs.mjs/_virtual/earcut.js +2 -2
- package/dist/melonjs.mjs/_virtual/howler.js +2 -2
- package/dist/melonjs.mjs/_virtual/index.js +2 -2
- package/dist/melonjs.mjs/_virtual/index2.js +2 -2
- package/dist/melonjs.mjs/_virtual/multimap.js +2 -2
- package/dist/melonjs.mjs/_virtual/setmultimap.js +2 -2
- package/dist/melonjs.mjs/application/application.js +141 -10
- package/dist/melonjs.mjs/application/header.js +34 -0
- package/dist/melonjs.mjs/application/resize.js +4 -2
- package/dist/melonjs.mjs/application/settings.js +28 -0
- package/dist/melonjs.mjs/audio/audio.js +2 -2
- package/dist/melonjs.mjs/camera/camera2d.js +3 -3
- package/dist/melonjs.mjs/const.js +32 -0
- package/dist/melonjs.mjs/entity/entity.js +2 -2
- package/dist/melonjs.mjs/game.js +1 -1
- package/dist/melonjs.mjs/geometries/ellipse.js +2 -2
- package/dist/melonjs.mjs/geometries/line.js +2 -2
- package/dist/melonjs.mjs/geometries/path2d.js +2 -2
- package/dist/melonjs.mjs/geometries/point.js +2 -2
- package/dist/melonjs.mjs/geometries/poly.js +2 -2
- package/dist/melonjs.mjs/geometries/rectangle.js +2 -2
- package/dist/melonjs.mjs/geometries/roundrect.js +2 -2
- package/dist/melonjs.mjs/index.js +44 -33
- package/dist/melonjs.mjs/input/gamepad.js +2 -2
- package/dist/melonjs.mjs/input/input.js +2 -2
- package/dist/melonjs.mjs/input/keyboard.js +2 -2
- package/dist/melonjs.mjs/input/pointer.js +3 -3
- package/dist/melonjs.mjs/input/pointerevent.js +3 -3
- package/dist/melonjs.mjs/lang/console.js +44 -0
- package/dist/melonjs.mjs/lang/deprecated.js +4 -40
- package/dist/melonjs.mjs/level/level.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +2 -23
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +68 -58
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +2 -64
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +10 -26
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +18 -84
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +2 -16
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +3 -10
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +37 -14
- package/dist/melonjs.mjs/level/tiled/constants.js +17 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +3 -6
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -14
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +38 -0
- package/dist/melonjs.mjs/loader/loader.js +5 -3
- package/dist/melonjs.mjs/loader/loadingscreen.js +3 -3
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +2 -2
- package/dist/melonjs.mjs/math/color.js +2 -2
- package/dist/melonjs.mjs/math/math.js +2 -2
- package/dist/melonjs.mjs/math/matrix2.js +2 -2
- package/dist/melonjs.mjs/math/matrix3.js +2 -2
- package/dist/melonjs.mjs/math/observable_vector2.js +2 -2
- package/dist/melonjs.mjs/math/observable_vector3.js +2 -2
- package/dist/melonjs.mjs/math/vector2.js +2 -2
- package/dist/melonjs.mjs/math/vector3.js +2 -2
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +2 -2
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +2 -2
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +2 -2
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +2 -2
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +2 -2
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +2 -2
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +2 -2
- package/dist/melonjs.mjs/particles/emitter.js +2 -2
- package/dist/melonjs.mjs/particles/particle.js +2 -2
- package/dist/melonjs.mjs/particles/settings.js +2 -2
- package/dist/melonjs.mjs/physics/body.js +2 -2
- package/dist/melonjs.mjs/physics/bounds.js +2 -2
- package/dist/melonjs.mjs/physics/collision.js +4 -4
- package/dist/melonjs.mjs/physics/detector.js +175 -147
- package/dist/melonjs.mjs/physics/quadtree.js +2 -2
- package/dist/melonjs.mjs/physics/response.js +2 -2
- package/dist/melonjs.mjs/physics/sat.js +2 -2
- package/dist/melonjs.mjs/physics/world.js +11 -31
- package/dist/melonjs.mjs/plugin/plugin.js +4 -4
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +2 -2
- package/dist/melonjs.mjs/renderable/container.js +4 -88
- package/dist/melonjs.mjs/renderable/dragndrop.js +2 -2
- package/dist/melonjs.mjs/renderable/imagelayer.js +3 -3
- package/dist/melonjs.mjs/renderable/light2d.js +2 -2
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
- package/dist/melonjs.mjs/renderable/renderable.js +2 -2
- package/dist/melonjs.mjs/renderable/sprite.js +2 -2
- package/dist/melonjs.mjs/renderable/trigger.js +3 -3
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +2 -2
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +2 -2
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +2 -2
- package/dist/melonjs.mjs/state/stage.js +3 -3
- package/dist/melonjs.mjs/state/state.js +3 -3
- package/dist/melonjs.mjs/system/device.js +3 -23
- package/dist/melonjs.mjs/system/dom.js +2 -2
- package/dist/melonjs.mjs/system/event.js +2 -2
- package/dist/melonjs.mjs/system/platform.js +2 -2
- package/dist/melonjs.mjs/system/pooling.js +2 -2
- package/dist/melonjs.mjs/system/save.js +2 -2
- package/dist/melonjs.mjs/system/timer.js +2 -2
- package/dist/melonjs.mjs/text/bitmaptext.js +2 -2
- package/dist/melonjs.mjs/text/bitmaptextdata.js +2 -2
- package/dist/melonjs.mjs/text/glyph.js +2 -2
- package/dist/melonjs.mjs/text/text.js +2 -2
- package/dist/melonjs.mjs/text/textmetrics.js +2 -2
- package/dist/melonjs.mjs/text/textstyle.js +2 -2
- package/dist/melonjs.mjs/tweens/easing.js +2 -2
- package/dist/melonjs.mjs/tweens/interpolation.js +2 -2
- package/dist/melonjs.mjs/tweens/tween.js +3 -3
- package/dist/melonjs.mjs/utils/agent.js +2 -2
- package/dist/melonjs.mjs/utils/array.js +2 -2
- package/dist/melonjs.mjs/utils/file.js +2 -2
- package/dist/melonjs.mjs/utils/function.js +2 -2
- package/dist/melonjs.mjs/utils/string.js +2 -2
- package/dist/melonjs.mjs/utils/utils.js +2 -2
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +5 -2
- package/dist/melonjs.mjs/video/renderer.js +9 -2
- package/dist/melonjs.mjs/video/texture/atlas.js +2 -2
- package/dist/melonjs.mjs/video/texture/cache.js +2 -2
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +4 -3
- 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 +29 -158
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +2 -2
- package/dist/melonjs.mjs/video/webgl/glshader.js +3 -4
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +21 -3
- package/dist/melonjs.mjs/video/webgl/utils/program.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/string.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +2 -2
- package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +2 -2
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +5 -2
- package/dist/melonjs.module.js +20845 -20968
- package/dist/types/application/application.d.ts +148 -0
- package/dist/types/application/header.d.ts +5 -0
- package/dist/types/application/resize.d.ts +6 -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/const.d.ts +21 -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 +4 -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/console.d.ts +7 -0
- package/dist/types/lang/deprecated.d.ts +45 -0
- package/dist/types/level/level.d.ts +134 -0
- package/dist/types/level/tiled/TMXGroup.d.ts +61 -0
- package/dist/types/level/tiled/TMXLayer.d.ts +158 -0
- package/dist/types/level/tiled/TMXObject.d.ts +133 -0
- package/dist/types/level/tiled/TMXTile.d.ts +64 -0
- package/dist/types/level/tiled/TMXTileMap.d.ts +142 -0
- package/dist/types/level/tiled/TMXTileset.d.ts +80 -0
- package/dist/types/level/tiled/TMXTilesetGroup.d.ts +26 -0
- package/dist/types/level/tiled/TMXUtils.d.ts +47 -0
- package/dist/types/level/tiled/constants.d.ts +5 -0
- package/dist/types/level/tiled/renderer/TMXHexagonalRenderer.d.ts +83 -0
- package/dist/types/level/tiled/renderer/TMXIsometricRenderer.d.ts +51 -0
- package/dist/types/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +43 -0
- package/dist/types/level/tiled/renderer/TMXRenderer.d.ts +63 -0
- package/dist/types/level/tiled/renderer/TMXStaggeredRenderer.d.ts +8 -0
- package/dist/types/level/tiled/renderer/autodetect.d.ts +9 -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 +93 -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 +8 -8
- package/src/application/application.js +138 -7
- package/src/application/header.js +25 -0
- package/src/{video/utils → application}/resize.js +11 -6
- package/src/application/settings.js +19 -0
- package/src/camera/camera2d.js +1 -1
- package/src/const.js +23 -0
- package/src/index.js +36 -23
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +1 -1
- package/src/lang/console.js +36 -0
- package/src/lang/deprecated.js +2 -37
- package/src/level/level.js +1 -1
- package/src/level/tiled/TMXGroup.js +0 -21
- package/src/level/tiled/TMXLayer.js +66 -56
- package/src/level/tiled/TMXObject.js +0 -62
- package/src/level/tiled/TMXTile.js +8 -24
- package/src/level/tiled/TMXTileMap.js +17 -83
- package/src/level/tiled/TMXTileset.js +0 -14
- package/src/level/tiled/TMXTilesetGroup.js +1 -9
- package/src/level/tiled/TMXUtils.js +38 -15
- package/src/level/tiled/constants.js +8 -0
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +5 -6
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -4
- package/src/level/tiled/renderer/TMXRenderer.js +0 -12
- package/src/level/tiled/renderer/autodetect.js +29 -0
- package/src/loader/loader.js +3 -1
- 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 +26 -155
- 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
- package/dist/melonjs.mjs/node_modules/core-js/es/string/trim-end.js +0 -13
- package/dist/melonjs.mjs/node_modules/core-js/es/string/trim-start.js +0 -13
- package/dist/melonjs.mjs/node_modules/core-js/internals/a-callable.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/an-object.js +0 -21
- package/dist/melonjs.mjs/node_modules/core-js/internals/array-includes.js +0 -45
- package/dist/melonjs.mjs/node_modules/core-js/internals/classof-raw.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/classof.js +0 -43
- package/dist/melonjs.mjs/node_modules/core-js/internals/copy-constructor-properties.js +0 -32
- package/dist/melonjs.mjs/node_modules/core-js/internals/create-non-enumerable-property.js +0 -24
- package/dist/melonjs.mjs/node_modules/core-js/internals/create-property-descriptor.js +0 -17
- package/dist/melonjs.mjs/node_modules/core-js/internals/define-built-in.js +0 -43
- package/dist/melonjs.mjs/node_modules/core-js/internals/define-global-property.js +0 -23
- package/dist/melonjs.mjs/node_modules/core-js/internals/descriptors.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/document-all.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/document-create-element.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/engine-user-agent.js +0 -14
- package/dist/melonjs.mjs/node_modules/core-js/internals/engine-v8-version.js +0 -39
- package/dist/melonjs.mjs/node_modules/core-js/internals/entry-unbind.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/enum-bug-keys.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/export.js +0 -72
- package/dist/melonjs.mjs/node_modules/core-js/internals/fails.js +0 -16
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-bind-native.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-call.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-name.js +0 -29
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-uncurry-this.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/get-built-in.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/get-method.js +0 -21
- package/dist/melonjs.mjs/node_modules/core-js/internals/global.js +0 -25
- package/dist/melonjs.mjs/node_modules/core-js/internals/has-own-property.js +0 -23
- package/dist/melonjs.mjs/node_modules/core-js/internals/hidden-keys.js +0 -10
- package/dist/melonjs.mjs/node_modules/core-js/internals/ie8-dom-define.js +0 -24
- package/dist/melonjs.mjs/node_modules/core-js/internals/indexed-object.js +0 -28
- package/dist/melonjs.mjs/node_modules/core-js/internals/inspect-source.js +0 -27
- package/dist/melonjs.mjs/node_modules/core-js/internals/internal-state.js +0 -88
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-callable.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-forced.js +0 -34
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-null-or-undefined.js +0 -14
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-object.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-symbol.js +0 -27
- package/dist/melonjs.mjs/node_modules/core-js/internals/length-of-array-like.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/make-built-in.js +0 -68
- package/dist/melonjs.mjs/node_modules/core-js/internals/math-trunc.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-define-property.js +0 -58
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-descriptor.js +0 -41
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-names.js +0 -23
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-symbols.js +0 -12
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-is-prototype-of.js +0 -14
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-keys-internal.js +0 -35
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-property-is-enumerable.js +0 -23
- package/dist/melonjs.mjs/node_modules/core-js/internals/ordinary-to-primitive.js +0 -28
- package/dist/melonjs.mjs/node_modules/core-js/internals/own-keys.js +0 -31
- package/dist/melonjs.mjs/node_modules/core-js/internals/require-object-coercible.js +0 -21
- package/dist/melonjs.mjs/node_modules/core-js/internals/shared-key.js +0 -21
- package/dist/melonjs.mjs/node_modules/core-js/internals/shared-store.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/shared.js +0 -24
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-end.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-forced.js +0 -28
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-start.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim.js +0 -45
- package/dist/melonjs.mjs/node_modules/core-js/internals/symbol-constructor-detection.js +0 -26
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-absolute-index.js +0 -23
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-indexed-object.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-integer-or-infinity.js +0 -20
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-length.js +0 -20
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-object.js +0 -20
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-primitive.js +0 -41
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-property-key.js +0 -21
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-string-tag-support.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-string.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/try-to-string.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/uid.js +0 -20
- package/dist/melonjs.mjs/node_modules/core-js/internals/use-symbol-as-uid.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/v8-prototype-define-bug.js +0 -24
- package/dist/melonjs.mjs/node_modules/core-js/internals/weak-map-basic-detection.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/well-known-symbol.js +0 -41
- package/dist/melonjs.mjs/node_modules/core-js/internals/whitespaces.js +0 -12
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.global-this.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-end.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-left.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-right.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-start.js +0 -22
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.mjs.js +0 -9
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* Particle Emitter Object.
|
|
4
|
+
* @augments Container
|
|
5
|
+
*/
|
|
6
|
+
export default class ParticleEmitter extends Container {
|
|
7
|
+
/**
|
|
8
|
+
* @param {number} x - x position of the particle emitter
|
|
9
|
+
* @param {number} y - y position of the particle emitter
|
|
10
|
+
* @param {ParticleEmitterSettings} [settings=ParticleEmitterSettings] - the settings for the particle emitter.
|
|
11
|
+
* @example
|
|
12
|
+
* // Create a particle emitter at position 100, 100
|
|
13
|
+
* var emitter = new ParticleEmitter(100, 100, {
|
|
14
|
+
* width: 16,
|
|
15
|
+
* height : 16,
|
|
16
|
+
* tint: "#f00",
|
|
17
|
+
* totalParticles: 32,
|
|
18
|
+
* angle: 0,
|
|
19
|
+
* angleVariation: 6.283185307179586,
|
|
20
|
+
* maxLife: 5,
|
|
21
|
+
* speed: 3
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Add the emitter to the game world
|
|
25
|
+
* me.game.world.addChild(emitter);
|
|
26
|
+
*
|
|
27
|
+
* // Launch all particles one time and stop, like a explosion
|
|
28
|
+
* emitter.burstParticles();
|
|
29
|
+
*
|
|
30
|
+
* // Launch constantly the particles, like a fountain
|
|
31
|
+
* emitter.streamParticles();
|
|
32
|
+
*
|
|
33
|
+
* // At the end, remove emitter from the game world
|
|
34
|
+
* // call this in onDestroyEvent function
|
|
35
|
+
* me.game.world.removeChild(emitter);
|
|
36
|
+
*/
|
|
37
|
+
constructor(x: number, y: number, settings?: {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
image: HTMLCanvasElement;
|
|
41
|
+
textureSize: number;
|
|
42
|
+
tint: string;
|
|
43
|
+
totalParticles: number;
|
|
44
|
+
angle: number;
|
|
45
|
+
angleVariation: number;
|
|
46
|
+
minLife: number;
|
|
47
|
+
maxLife: number;
|
|
48
|
+
speed: number;
|
|
49
|
+
speedVariation: number;
|
|
50
|
+
minRotation: number;
|
|
51
|
+
maxRotation: number;
|
|
52
|
+
minStartScale: number;
|
|
53
|
+
maxStartScale: number;
|
|
54
|
+
minEndScale: number;
|
|
55
|
+
maxEndScale: number;
|
|
56
|
+
gravity: number;
|
|
57
|
+
wind: number;
|
|
58
|
+
followTrajectory: boolean;
|
|
59
|
+
textureAdditive: boolean;
|
|
60
|
+
blendMode: string;
|
|
61
|
+
onlyInViewport: boolean;
|
|
62
|
+
floating: boolean;
|
|
63
|
+
maxParticles: number;
|
|
64
|
+
frequency: number;
|
|
65
|
+
duration: number;
|
|
66
|
+
framesToSkip: number;
|
|
67
|
+
} | undefined);
|
|
68
|
+
/**
|
|
69
|
+
* the current (active) emitter settings
|
|
70
|
+
* @public
|
|
71
|
+
* @type {ParticleEmitterSettings}
|
|
72
|
+
* @name settings
|
|
73
|
+
* @memberof ParticleEmitter
|
|
74
|
+
*/
|
|
75
|
+
public settings: {
|
|
76
|
+
width: number;
|
|
77
|
+
height: number;
|
|
78
|
+
image: HTMLCanvasElement;
|
|
79
|
+
textureSize: number;
|
|
80
|
+
tint: string;
|
|
81
|
+
totalParticles: number;
|
|
82
|
+
angle: number;
|
|
83
|
+
angleVariation: number;
|
|
84
|
+
minLife: number;
|
|
85
|
+
maxLife: number;
|
|
86
|
+
speed: number;
|
|
87
|
+
speedVariation: number;
|
|
88
|
+
minRotation: number;
|
|
89
|
+
maxRotation: number;
|
|
90
|
+
minStartScale: number;
|
|
91
|
+
maxStartScale: number;
|
|
92
|
+
minEndScale: number;
|
|
93
|
+
maxEndScale: number;
|
|
94
|
+
gravity: number;
|
|
95
|
+
wind: number;
|
|
96
|
+
followTrajectory: boolean;
|
|
97
|
+
textureAdditive: boolean;
|
|
98
|
+
blendMode: string;
|
|
99
|
+
onlyInViewport: boolean;
|
|
100
|
+
floating: boolean;
|
|
101
|
+
maxParticles: number;
|
|
102
|
+
frequency: number;
|
|
103
|
+
duration: number;
|
|
104
|
+
framesToSkip: number;
|
|
105
|
+
};
|
|
106
|
+
/** @ignore */
|
|
107
|
+
_stream: boolean;
|
|
108
|
+
/** @ignore */
|
|
109
|
+
_frequencyTimer: number;
|
|
110
|
+
/** @ignore */
|
|
111
|
+
_durationTimer: number;
|
|
112
|
+
/** @ignore */
|
|
113
|
+
_enabled: boolean;
|
|
114
|
+
_updateCount: number;
|
|
115
|
+
_dt: number;
|
|
116
|
+
/**
|
|
117
|
+
* Reset the emitter with particle emitter settings.
|
|
118
|
+
* @param {ParticleEmitterSettings} settings - [optional] object with emitter settings. See {@link ParticleEmitterSettings}
|
|
119
|
+
*/
|
|
120
|
+
reset(settings?: {
|
|
121
|
+
width: number;
|
|
122
|
+
height: number;
|
|
123
|
+
image: HTMLCanvasElement;
|
|
124
|
+
textureSize: number;
|
|
125
|
+
tint: string;
|
|
126
|
+
totalParticles: number;
|
|
127
|
+
angle: number;
|
|
128
|
+
angleVariation: number;
|
|
129
|
+
minLife: number;
|
|
130
|
+
maxLife: number;
|
|
131
|
+
speed: number;
|
|
132
|
+
speedVariation: number;
|
|
133
|
+
minRotation: number;
|
|
134
|
+
maxRotation: number;
|
|
135
|
+
minStartScale: number;
|
|
136
|
+
maxStartScale: number;
|
|
137
|
+
minEndScale: number;
|
|
138
|
+
maxEndScale: number;
|
|
139
|
+
gravity: number;
|
|
140
|
+
wind: number;
|
|
141
|
+
followTrajectory: boolean;
|
|
142
|
+
textureAdditive: boolean;
|
|
143
|
+
blendMode: string;
|
|
144
|
+
onlyInViewport: boolean;
|
|
145
|
+
floating: boolean;
|
|
146
|
+
maxParticles: number;
|
|
147
|
+
frequency: number;
|
|
148
|
+
duration: number;
|
|
149
|
+
framesToSkip: number;
|
|
150
|
+
}): void;
|
|
151
|
+
_defaultParticle: object | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* returns a random point on the x axis within the bounds of this emitter
|
|
154
|
+
* @returns {number}
|
|
155
|
+
*/
|
|
156
|
+
getRandomPointX(): number;
|
|
157
|
+
/**
|
|
158
|
+
* returns a random point on the y axis within the bounds this emitter
|
|
159
|
+
* @returns {number}
|
|
160
|
+
*/
|
|
161
|
+
getRandomPointY(): number;
|
|
162
|
+
/** @ignore */
|
|
163
|
+
addParticles(count: any): void;
|
|
164
|
+
/**
|
|
165
|
+
* Emitter is of type stream and is launching particles
|
|
166
|
+
* @returns {boolean} Emitter is Stream and is launching particles
|
|
167
|
+
*/
|
|
168
|
+
isRunning(): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Launch particles from emitter constantly (e.g. for stream)
|
|
171
|
+
* @param {number} duration - [optional] time that the emitter releases particles in ms
|
|
172
|
+
*/
|
|
173
|
+
streamParticles(duration: number): void;
|
|
174
|
+
/**
|
|
175
|
+
* Stop the emitter from generating new particles (used only if emitter is Stream)
|
|
176
|
+
*/
|
|
177
|
+
stopStream(): void;
|
|
178
|
+
/**
|
|
179
|
+
* Launch all particles from emitter and stop (e.g. for explosion)
|
|
180
|
+
* @param {number} total - [optional] number of particles to launch
|
|
181
|
+
*/
|
|
182
|
+
burstParticles(total: number): void;
|
|
183
|
+
/**
|
|
184
|
+
* @ignore
|
|
185
|
+
*/
|
|
186
|
+
update(dt: any): boolean;
|
|
187
|
+
}
|
|
188
|
+
import Container from "./../renderable/container.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* Single Particle Object.
|
|
4
|
+
* @augments Renderable
|
|
5
|
+
*/
|
|
6
|
+
export default class Particle extends Renderable {
|
|
7
|
+
/**
|
|
8
|
+
* @param {ParticleEmitter} emitter - the particle emitter
|
|
9
|
+
*/
|
|
10
|
+
constructor(emitter: ParticleEmitter);
|
|
11
|
+
/**
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
onResetEvent(emitter: any, newInstance?: boolean): void;
|
|
15
|
+
vel: object | undefined;
|
|
16
|
+
image: any;
|
|
17
|
+
life: any;
|
|
18
|
+
startLife: any;
|
|
19
|
+
startScale: number | undefined;
|
|
20
|
+
endScale: number | undefined;
|
|
21
|
+
gravity: any;
|
|
22
|
+
wind: any;
|
|
23
|
+
followTrajectory: any;
|
|
24
|
+
onlyInViewport: any;
|
|
25
|
+
_deltaInv: number | undefined;
|
|
26
|
+
angle: number | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* @ignore
|
|
29
|
+
*/
|
|
30
|
+
draw(renderer: any): void;
|
|
31
|
+
}
|
|
32
|
+
import Renderable from "./../renderable/renderable.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default ParticleEmitterSettings;
|
|
2
|
+
declare namespace ParticleEmitterSettings {
|
|
3
|
+
const width: number;
|
|
4
|
+
const height: number;
|
|
5
|
+
const image: HTMLCanvasElement;
|
|
6
|
+
const textureSize: number;
|
|
7
|
+
const tint: string;
|
|
8
|
+
const totalParticles: number;
|
|
9
|
+
const angle: number;
|
|
10
|
+
const angleVariation: number;
|
|
11
|
+
const minLife: number;
|
|
12
|
+
const maxLife: number;
|
|
13
|
+
const speed: number;
|
|
14
|
+
const speedVariation: number;
|
|
15
|
+
const minRotation: number;
|
|
16
|
+
const maxRotation: number;
|
|
17
|
+
const minStartScale: number;
|
|
18
|
+
const maxStartScale: number;
|
|
19
|
+
const minEndScale: number;
|
|
20
|
+
const maxEndScale: number;
|
|
21
|
+
const gravity: number;
|
|
22
|
+
const wind: number;
|
|
23
|
+
const followTrajectory: boolean;
|
|
24
|
+
const textureAdditive: boolean;
|
|
25
|
+
const blendMode: string;
|
|
26
|
+
const onlyInViewport: boolean;
|
|
27
|
+
const floating: boolean;
|
|
28
|
+
const maxParticles: number;
|
|
29
|
+
const frequency: number;
|
|
30
|
+
const duration: number;
|
|
31
|
+
const framesToSkip: number;
|
|
32
|
+
}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a Generic Physic Body Object with some physic properties and behavior functionality, to as a member of a Renderable.
|
|
4
|
+
* @see Renderable.body
|
|
5
|
+
*/
|
|
6
|
+
export default class Body {
|
|
7
|
+
/**
|
|
8
|
+
* @param {Renderable} ancestor - the parent object this body is attached to
|
|
9
|
+
* @param {Rect|Rect[]|Polygon|Polygon[]|Line|Line[]|Ellipse|Ellipse[]|Point|Point[]|Bounds|Bounds[]|object} [shapes] - a initial shape, list of shapes, or JSON object defining the body
|
|
10
|
+
* @param {Function} [onBodyUpdate] - callback for when the body is updated (e.g. add/remove shapes)
|
|
11
|
+
*/
|
|
12
|
+
constructor(ancestor: Renderable, shapes?: Rect | Rect[] | Polygon | Polygon[] | Line | Line[] | Ellipse | Ellipse[] | Point | Point[] | Bounds | Bounds[] | object, onBodyUpdate?: Function | undefined);
|
|
13
|
+
/**
|
|
14
|
+
* a reference to the parent object that contains this body,
|
|
15
|
+
* or undefined if it has not been added to one.
|
|
16
|
+
* @public
|
|
17
|
+
* @type {Renderable}
|
|
18
|
+
* @default undefined
|
|
19
|
+
*/
|
|
20
|
+
public ancestor: Renderable;
|
|
21
|
+
/**
|
|
22
|
+
* The AABB bounds box reprensenting this body
|
|
23
|
+
* @public
|
|
24
|
+
* @type {Bounds}
|
|
25
|
+
*/
|
|
26
|
+
public bounds: Bounds;
|
|
27
|
+
/**
|
|
28
|
+
* The collision shapes of the body
|
|
29
|
+
* @ignore
|
|
30
|
+
* @type {Polygon[]|Line[]|Ellipse[]|Point|Point[]}
|
|
31
|
+
*/
|
|
32
|
+
shapes: Polygon[] | Line[] | Ellipse[] | Point | Point[];
|
|
33
|
+
/**
|
|
34
|
+
* The body collision mask, that defines what should collide with what.<br>
|
|
35
|
+
* (by default will collide with all entities)
|
|
36
|
+
* @ignore
|
|
37
|
+
* @type {number}
|
|
38
|
+
* @default collision.types.ALL_OBJECT
|
|
39
|
+
* @see collision.types
|
|
40
|
+
*/
|
|
41
|
+
collisionMask: number;
|
|
42
|
+
/**
|
|
43
|
+
* define the collision type of the body for collision filtering
|
|
44
|
+
* @public
|
|
45
|
+
* @type {number}
|
|
46
|
+
* @default collision.types.ENEMY_OBJECT
|
|
47
|
+
* @see collision.types
|
|
48
|
+
* @example
|
|
49
|
+
* // set the body collision type
|
|
50
|
+
* body.collisionType = me.collision.types.PLAYER_OBJECT;
|
|
51
|
+
*/
|
|
52
|
+
public collisionType: number;
|
|
53
|
+
/**
|
|
54
|
+
* The current velocity of the body.
|
|
55
|
+
* See to apply a force if you need to modify a body velocity
|
|
56
|
+
* @see Body.force
|
|
57
|
+
* @public
|
|
58
|
+
* @type {Vector2d}
|
|
59
|
+
* @default <0,0>
|
|
60
|
+
*/
|
|
61
|
+
public vel: Vector2d;
|
|
62
|
+
/**
|
|
63
|
+
* body force to apply to this the body in the current step.
|
|
64
|
+
* (any positive or negative force will be cancelled after every world/body update cycle)
|
|
65
|
+
* @public
|
|
66
|
+
* @type {Vector2d}
|
|
67
|
+
* @default <0,0>
|
|
68
|
+
* @see Body.setMaxVelocity
|
|
69
|
+
* @example
|
|
70
|
+
* // define a default maximum acceleration, initial force and friction
|
|
71
|
+
* this.body.force.set(1, 0);
|
|
72
|
+
* this.body.friction.set(0.4, 0);
|
|
73
|
+
* this.body.setMaxVelocity(3, 15);
|
|
74
|
+
*
|
|
75
|
+
* // apply a postive or negative force when pressing left of right key
|
|
76
|
+
* update(dt) {
|
|
77
|
+
* if (me.input.isKeyPressed("left")) {
|
|
78
|
+
* this.body.force.x = -this.body.maxVel.x;
|
|
79
|
+
* } else if (me.input.isKeyPressed("right")) {
|
|
80
|
+
* this.body.force.x = this.body.maxVel.x;
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
*/
|
|
84
|
+
public force: Vector2d;
|
|
85
|
+
/**
|
|
86
|
+
* body friction
|
|
87
|
+
* @public
|
|
88
|
+
* @type {Vector2d}
|
|
89
|
+
* @default <0,0>
|
|
90
|
+
*/
|
|
91
|
+
public friction: Vector2d;
|
|
92
|
+
/**
|
|
93
|
+
* the body bouciness level when colliding with other solid bodies :
|
|
94
|
+
* a value of 0 will not bounce, a value of 1 will fully rebound.
|
|
95
|
+
* @public
|
|
96
|
+
* @type {number}
|
|
97
|
+
* @default 0
|
|
98
|
+
*/
|
|
99
|
+
public bounce: number;
|
|
100
|
+
/**
|
|
101
|
+
* the body mass
|
|
102
|
+
* @public
|
|
103
|
+
* @type {number}
|
|
104
|
+
* @default 1
|
|
105
|
+
*/
|
|
106
|
+
public mass: number;
|
|
107
|
+
/**
|
|
108
|
+
* max velocity (to limit body velocity)
|
|
109
|
+
* @public
|
|
110
|
+
* @type {Vector2d}
|
|
111
|
+
* @default <490,490>
|
|
112
|
+
*/
|
|
113
|
+
public maxVel: Vector2d;
|
|
114
|
+
/**
|
|
115
|
+
* Either this body is a static body or not.
|
|
116
|
+
* A static body is completely fixed and can never change position or angle.
|
|
117
|
+
* @readonly
|
|
118
|
+
* @public
|
|
119
|
+
* @type {boolean}
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
public readonly isStatic: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* The degree to which this body is affected by the world gravity
|
|
125
|
+
* @public
|
|
126
|
+
* @see World.gravity
|
|
127
|
+
* @type {number}
|
|
128
|
+
* @default 1.0
|
|
129
|
+
*/
|
|
130
|
+
public gravityScale: number;
|
|
131
|
+
/**
|
|
132
|
+
* If true this body won't be affected by the world gravity
|
|
133
|
+
* @public
|
|
134
|
+
* @see World.gravity
|
|
135
|
+
* @type {boolean}
|
|
136
|
+
* @default false
|
|
137
|
+
*/
|
|
138
|
+
public ignoreGravity: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* falling state of the body<br>
|
|
141
|
+
* true if the object is falling<br>
|
|
142
|
+
* false if the object is standing on something<br>
|
|
143
|
+
* @readonly
|
|
144
|
+
* @public
|
|
145
|
+
* @type {boolean}
|
|
146
|
+
* @default false
|
|
147
|
+
*/
|
|
148
|
+
public readonly falling: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* jumping state of the body<br>
|
|
151
|
+
* equal true if the body is jumping<br>
|
|
152
|
+
* @readonly
|
|
153
|
+
* @public
|
|
154
|
+
* @type {boolean}
|
|
155
|
+
* @default false
|
|
156
|
+
*/
|
|
157
|
+
public readonly jumping: boolean;
|
|
158
|
+
onBodyUpdate: Function | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* set the body as a static body
|
|
161
|
+
* static body do not move automatically and do not check againt collision with others
|
|
162
|
+
* @param {boolean} [isStatic=true]
|
|
163
|
+
*/
|
|
164
|
+
setStatic(isStatic?: boolean | undefined): void;
|
|
165
|
+
/**
|
|
166
|
+
* add a collision shape to this body <br>
|
|
167
|
+
* (note: me.Rect objects will be converted to me.Polygon before being added)
|
|
168
|
+
* @param {Rect|Polygon|Line|Ellipse|Point|Point[]|Bounds|object} shape - a shape or JSON object
|
|
169
|
+
* @returns {number} the shape array length
|
|
170
|
+
* @example
|
|
171
|
+
* // add a rectangle shape
|
|
172
|
+
* this.body.addShape(new me.Rect(0, 0, image.width, image.height));
|
|
173
|
+
* // add a shape from a JSON object
|
|
174
|
+
* this.body.addShape(me.loader.getJSON("shapesdef").banana);
|
|
175
|
+
*/
|
|
176
|
+
addShape(shape: Rect | Polygon | Line | Ellipse | Point | Point[] | Bounds | object): number;
|
|
177
|
+
/**
|
|
178
|
+
* set the body vertices to the given one
|
|
179
|
+
* @param {Vector2d[]} vertices - an array of me.Vector2d points defining a convex hull
|
|
180
|
+
* @param {number} [index=0] - the shape object for which to set the vertices
|
|
181
|
+
* @param {boolean} [clear=true] - either to reset the body definition before adding the new vertices
|
|
182
|
+
*/
|
|
183
|
+
setVertices(vertices: Vector2d[], index?: number | undefined, clear?: boolean | undefined): void;
|
|
184
|
+
/**
|
|
185
|
+
* add the given vertices to the body shape
|
|
186
|
+
* @param {Vector2d[]} vertices - an array of me.Vector2d points defining a convex hull
|
|
187
|
+
* @param {number} [index=0] - the shape object for which to set the vertices
|
|
188
|
+
*/
|
|
189
|
+
addVertices(vertices: Vector2d[], index?: number | undefined): void;
|
|
190
|
+
/**
|
|
191
|
+
* add collision mesh based on a JSON object
|
|
192
|
+
* (this will also apply any physic properties defined in the given JSON file)
|
|
193
|
+
* @param {object} json - a JSON object as exported from a Physics Editor tool
|
|
194
|
+
* @param {string} [id] - an optional shape identifier within the given the json object
|
|
195
|
+
* @see https://www.codeandweb.com/physicseditor
|
|
196
|
+
* @returns {number} how many shapes were added to the body
|
|
197
|
+
* @example
|
|
198
|
+
* // define the body based on the banana shape
|
|
199
|
+
* this.body.fromJSON(me.loader.getJSON("shapesdef").banana);
|
|
200
|
+
* // or ...
|
|
201
|
+
* this.body.fromJSON(me.loader.getJSON("shapesdef"), "banana");
|
|
202
|
+
*/
|
|
203
|
+
fromJSON(json: object, id?: string | undefined): number;
|
|
204
|
+
/**
|
|
205
|
+
* return the collision shape at the given index
|
|
206
|
+
* @param {number} [index=0] - the shape object at the specified index
|
|
207
|
+
* @returns {Polygon|Line|Ellipse} shape a shape object if defined
|
|
208
|
+
*/
|
|
209
|
+
getShape(index?: number | undefined): Polygon | Line | Ellipse;
|
|
210
|
+
/**
|
|
211
|
+
* returns the AABB bounding box for this body
|
|
212
|
+
* @returns {Bounds} bounding box Rectangle object
|
|
213
|
+
*/
|
|
214
|
+
getBounds(): Bounds;
|
|
215
|
+
/**
|
|
216
|
+
* remove the specified shape from the body shape list
|
|
217
|
+
* @param {Polygon|Line|Ellipse} shape - a shape object
|
|
218
|
+
* @returns {number} the shape array length
|
|
219
|
+
*/
|
|
220
|
+
removeShape(shape: Polygon | Line | Ellipse): number;
|
|
221
|
+
/**
|
|
222
|
+
* remove the shape at the given index from the body shape list
|
|
223
|
+
* @param {number} index - the shape object at the specified index
|
|
224
|
+
* @returns {number} the shape array length
|
|
225
|
+
*/
|
|
226
|
+
removeShapeAt(index: number): number;
|
|
227
|
+
/**
|
|
228
|
+
* By default all physic bodies are able to collide with all other bodies, <br>
|
|
229
|
+
* but it's also possible to specify 'collision filters' to provide a finer <br>
|
|
230
|
+
* control over which body can collide with each other.
|
|
231
|
+
* @see collision.types
|
|
232
|
+
* @param {number} [bitmask = collision.types.ALL_OBJECT] - the collision mask
|
|
233
|
+
* @example
|
|
234
|
+
* // filter collision detection with collision shapes, enemies and collectables
|
|
235
|
+
* body.setCollisionMask(me.collision.types.WORLD_SHAPE | me.collision.types.ENEMY_OBJECT | me.collision.types.COLLECTABLE_OBJECT);
|
|
236
|
+
* ...
|
|
237
|
+
* // disable collision detection with all other objects
|
|
238
|
+
* body.setCollisionMask(me.collision.types.NO_OBJECT);
|
|
239
|
+
*/
|
|
240
|
+
setCollisionMask(bitmask?: number | undefined): void;
|
|
241
|
+
/**
|
|
242
|
+
* define the collision type of the body for collision filtering
|
|
243
|
+
* @see collision.types
|
|
244
|
+
* @param {number} type - the collision type
|
|
245
|
+
* @example
|
|
246
|
+
* // set the body collision type
|
|
247
|
+
* body.collisionType = me.collision.types.PLAYER_OBJECT;
|
|
248
|
+
*/
|
|
249
|
+
setCollisionType(type: number): void;
|
|
250
|
+
/**
|
|
251
|
+
* the built-in function to solve the collision response
|
|
252
|
+
* @param {object} response - the collision response object (see {@link ResponseObject})
|
|
253
|
+
*/
|
|
254
|
+
respondToCollision(response: object): void;
|
|
255
|
+
/**
|
|
256
|
+
* The forEach() method executes a provided function once per body shape element. <br>
|
|
257
|
+
* the callback function is invoked with three arguments: <br>
|
|
258
|
+
* - The current element being processed in the array <br>
|
|
259
|
+
* - The index of element in the array. <br>
|
|
260
|
+
* - The array forEach() was called upon. <br>
|
|
261
|
+
* @param {Function} callback - fnction to execute on each element
|
|
262
|
+
* @param {object} [thisArg] - value to use as this(i.e reference Object) when executing callback.
|
|
263
|
+
* @example
|
|
264
|
+
* // iterate through all shapes of the physic body
|
|
265
|
+
* mySprite.body.forEach((shape) => {
|
|
266
|
+
* shape.doSomething();
|
|
267
|
+
* });
|
|
268
|
+
* mySprite.body.forEach((shape, index) => { ... });
|
|
269
|
+
* mySprite.body.forEach((shape, index, array) => { ... });
|
|
270
|
+
* mySprite.body.forEach((shape, index, array) => { ... }, thisArg);
|
|
271
|
+
*/
|
|
272
|
+
forEach(callback: Function, thisArg?: object | undefined, ...args: any[]): void;
|
|
273
|
+
/**
|
|
274
|
+
* Returns true if the any of the shape composing the body contains the given point.
|
|
275
|
+
* @method Body#contains
|
|
276
|
+
* @param {Vector2d} point
|
|
277
|
+
* @returns {boolean} true if contains
|
|
278
|
+
*/
|
|
279
|
+
/**
|
|
280
|
+
* Returns true if the any of the shape composing the body contains the given point.
|
|
281
|
+
* @param {number} x - x coordinate
|
|
282
|
+
* @param {number} y - y coordinate
|
|
283
|
+
* @returns {boolean} true if contains
|
|
284
|
+
*/
|
|
285
|
+
contains(...args: any[]): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Rotate this body (counter-clockwise) by the specified angle (in radians).
|
|
288
|
+
* Unless specified the body will be rotated around its center point
|
|
289
|
+
* @param {number} angle - The angle to rotate (in radians)
|
|
290
|
+
* @param {Vector2d|ObservableVector2d} [v=Body.getBounds().center] - an optional point to rotate around
|
|
291
|
+
* @returns {Body} Reference to this object for method chaining
|
|
292
|
+
*/
|
|
293
|
+
rotate(angle: number, v?: Vector2d | ObservableVector2d): Body;
|
|
294
|
+
/**
|
|
295
|
+
* cap the body velocity (body.maxVel property) to the specified value<br>
|
|
296
|
+
* @param {number} x - max velocity on x axis
|
|
297
|
+
* @param {number} y - max velocity on y axis
|
|
298
|
+
*/
|
|
299
|
+
setMaxVelocity(x: number, y: number): void;
|
|
300
|
+
/**
|
|
301
|
+
* set the body default friction
|
|
302
|
+
* @param {number} x - horizontal friction
|
|
303
|
+
* @param {number} y - vertical friction
|
|
304
|
+
*/
|
|
305
|
+
setFriction(x?: number, y?: number): void;
|
|
306
|
+
/**
|
|
307
|
+
* Updates the parent's position as well as computes the new body's velocity based
|
|
308
|
+
* on the values of force/friction. Velocity chages are proportional to the
|
|
309
|
+
* me.timer.tick value (which can be used to scale velocities). The approach to moving the
|
|
310
|
+
* parent renderable is to compute new values of the Body.vel property then add them to
|
|
311
|
+
* the parent.pos value thus changing the postion the amount of Body.vel each time the
|
|
312
|
+
* update call is made. <br>
|
|
313
|
+
* Updates to Body.vel are bounded by maxVel (which defaults to viewport size if not set) <br>
|
|
314
|
+
* At this time a call to Body.Update does not call the onBodyUpdate callback that is listed in the constructor arguments.
|
|
315
|
+
* @protected
|
|
316
|
+
* @param {number} dt - time since the last update in milliseconds.
|
|
317
|
+
* @returns {boolean} true if resulting velocity is different than 0
|
|
318
|
+
*/
|
|
319
|
+
protected update(dt: number): boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Destroy function<br>
|
|
322
|
+
* @ignore
|
|
323
|
+
*/
|
|
324
|
+
destroy(): void;
|
|
325
|
+
}
|
|
326
|
+
import Bounds from "./bounds.js";
|
|
327
|
+
import Polygon from "./../geometries/poly.js";
|
|
328
|
+
import Ellipse from "./../geometries/ellipse.js";
|
|
329
|
+
import Point from "../geometries/point.js";
|
|
330
|
+
import Rect from "./../geometries/rectangle.js";
|