melonjs 20.7.0 → 20.9.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 +7 -3
- package/build/application/application.d.ts +66 -8
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +6 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -1
- package/build/application/header.d.ts.map +1 -1
- package/build/application/resize.d.ts +25 -0
- package/build/application/resize.d.ts.map +1 -1
- package/build/application/scaleMethods.d.ts +13 -3
- package/build/application/scaleMethods.d.ts.map +1 -1
- package/build/application/settings.d.ts +144 -5
- package/build/application/settings.d.ts.map +1 -1
- package/build/audio/audio.d.ts +29 -5
- package/build/audio/audio.d.ts.map +1 -1
- package/build/audio/autopause.d.ts +36 -0
- package/build/audio/autopause.d.ts.map +1 -0
- package/build/audio/backend/engine.d.ts +10 -1
- package/build/audio/backend/engine.d.ts.map +1 -1
- package/build/audio/backend/sound.d.ts +0 -1
- package/build/audio/backend/sound.d.ts.map +1 -1
- package/build/audio/backend/spatial.d.ts.map +1 -1
- package/build/audio/context.d.ts +35 -0
- package/build/audio/context.d.ts.map +1 -0
- package/build/audio/playback.d.ts.map +1 -1
- package/build/audio/procedural.d.ts.map +1 -1
- package/build/audio/spatial.d.ts +87 -0
- package/build/audio/spatial.d.ts.map +1 -0
- package/build/audio/state.d.ts +1 -0
- package/build/audio/state.d.ts.map +1 -1
- package/build/audio/types.d.ts +46 -6
- package/build/audio/types.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +95 -8
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/camera/effects/fade_effect.d.ts.map +1 -1
- package/build/camera/effects/mask_effect.d.ts.map +1 -1
- package/build/camera/effects/shake_effect.d.ts.map +1 -1
- package/build/geometries/box3d.d.ts +25 -7
- package/build/geometries/box3d.d.ts.map +1 -1
- package/build/geometries/ellipse.d.ts +15 -1
- package/build/geometries/ellipse.d.ts.map +1 -1
- package/build/geometries/line.d.ts +1 -1
- package/build/geometries/line.d.ts.map +1 -1
- package/build/geometries/point.d.ts +1 -1
- package/build/geometries/point.d.ts.map +1 -1
- package/build/geometries/polygon.d.ts +15 -1
- package/build/geometries/polygon.d.ts.map +1 -1
- package/build/geometries/rectangle.d.ts +1 -1
- package/build/geometries/rectangle.d.ts.map +1 -1
- package/build/geometries/roundrect.d.ts +1 -1
- package/build/geometries/roundrect.d.ts.map +1 -1
- package/build/geometries/sphere.d.ts +36 -7
- package/build/geometries/sphere.d.ts.map +1 -1
- package/build/index.d.ts +16 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +38172 -33633
- package/build/index.js.map +4 -4
- package/build/input/gamepad.d.ts +129 -3
- package/build/input/gamepad.d.ts.map +1 -1
- package/build/input/pointerevent.d.ts +8 -0
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/level/gltf/GLTFModel.d.ts +20 -33
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts +40 -1
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/level.d.ts +35 -0
- package/build/level/level.d.ts.map +1 -1
- package/build/level/tiled/TMXLayer.d.ts +5 -2
- package/build/level/tiled/TMXLayer.d.ts.map +1 -1
- package/build/level/tiled/TMXObject.d.ts +0 -1
- package/build/level/tiled/TMXObjectFactory.d.ts +3 -2
- package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
- package/build/level/tiled/TMXTile.d.ts +2 -1
- package/build/level/tiled/TMXTile.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts +7 -4
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/TMXTileset.d.ts +1 -1
- package/build/level/tiled/TMXTileset.d.ts.map +1 -1
- package/build/level/tiled/TMXTilesetGroup.d.ts +5 -0
- package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -1
- package/build/level/tiled/factories/shape.d.ts +0 -1
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +6 -5
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +5 -0
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +5 -7
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +5 -0
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXRenderer.d.ts +19 -4
- package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/autodetect.d.ts +0 -4
- package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
- package/build/loader/cache.d.ts +220 -0
- package/build/loader/cache.d.ts.map +1 -1
- package/build/loader/loader.d.ts +20 -340
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/loadingscreen.d.ts +1 -2
- package/build/loader/loadingscreen.d.ts.map +1 -1
- package/build/loader/parsers/gltf.d.ts +115 -0
- package/build/loader/parsers/gltf.d.ts.map +1 -1
- package/build/loader/parsers/shader.d.ts +0 -2
- package/build/math/color.d.ts +28 -5
- package/build/math/color.d.ts.map +1 -1
- package/build/math/matrix2d.d.ts +1 -1
- package/build/math/matrix2d.d.ts.map +1 -1
- package/build/math/matrix3d.d.ts +1 -1
- package/build/math/matrix3d.d.ts.map +1 -1
- package/build/math/observableVector2d.d.ts +14 -2
- package/build/math/observableVector2d.d.ts.map +1 -1
- package/build/math/observableVector3d.d.ts +15 -1
- package/build/math/observableVector3d.d.ts.map +1 -1
- package/build/math/vector2d.d.ts +31 -1
- package/build/math/vector2d.d.ts.map +1 -1
- package/build/math/vector3d.d.ts +38 -1
- package/build/math/vector3d.d.ts.map +1 -1
- package/build/math/vertex.d.ts.map +1 -1
- package/build/particles/emitter.d.ts.map +1 -1
- package/build/particles/particle.d.ts +29 -2
- package/build/particles/particle.d.ts.map +1 -1
- package/build/particles/settings.d.ts +104 -0
- package/build/particles/settings.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +9 -1
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/bounds.d.ts +1 -1
- package/build/physics/bounds.d.ts.map +1 -1
- package/build/physics/broadphase/octree.d.ts +24 -0
- package/build/physics/broadphase/octree.d.ts.map +1 -1
- package/build/physics/broadphase/quadtree.d.ts +31 -0
- package/build/physics/broadphase/quadtree.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +17 -2
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts +0 -1
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/physics/builtin/sat.d.ts +0 -7
- package/build/physics/builtin/sat3d.d.ts +46 -0
- package/build/physics/builtin/sat3d.d.ts.map +1 -1
- package/build/physics/response.d.ts +45 -62
- package/build/physics/response.d.ts.map +1 -1
- package/build/pool.d.ts +4 -0
- package/build/pool.d.ts.map +1 -1
- package/build/renderable/collectable.d.ts +6 -1
- package/build/renderable/collectable.d.ts.map +1 -1
- package/build/renderable/colorlayer.d.ts +17 -4
- package/build/renderable/colorlayer.d.ts.map +1 -1
- package/build/renderable/container.d.ts +23 -17
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts +12 -16
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/frameAnimation.d.ts +1 -1
- package/build/renderable/groundshadow.d.ts +1 -0
- package/build/renderable/groundshadow.d.ts.map +1 -1
- package/build/renderable/imagelayer.d.ts +12 -5
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/instanced_mesh.d.ts +56 -7
- package/build/renderable/instanced_mesh.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +369 -4
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/nineslicesprite.d.ts +3 -13
- package/build/renderable/nineslicesprite.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +129 -28
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +7 -20
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +31 -16
- package/build/renderable/sprite3d.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +76 -5
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/bitmaptextdata.d.ts +1 -5
- package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
- package/build/renderable/text/glypheffect.d.ts +44 -0
- package/build/renderable/text/glypheffect.d.ts.map +1 -0
- package/build/renderable/text/text.d.ts +22 -3
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/renderable/text/textmetrics.d.ts +2 -0
- package/build/renderable/text/textmetrics.d.ts.map +1 -1
- package/build/renderable/trail.d.ts +0 -1
- package/build/renderable/trail.d.ts.map +1 -1
- package/build/renderable/trail3d.d.ts +174 -0
- package/build/renderable/trail3d.d.ts.map +1 -0
- package/build/renderable/trigger.d.ts +28 -5
- package/build/renderable/trigger.d.ts.map +1 -1
- package/build/renderable/ui/panelpaint.d.ts +5 -0
- package/build/renderable/ui/panelpaint.d.ts.map +1 -0
- package/build/renderable/ui/progressbar.d.ts +192 -0
- package/build/renderable/ui/progressbar.d.ts.map +1 -0
- package/build/renderable/ui/uibaseelement.d.ts +48 -3
- package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
- package/build/renderable/ui/uipanel.d.ts +245 -0
- package/build/renderable/ui/uipanel.d.ts.map +1 -0
- package/build/renderable/ui/uispriteelement.d.ts +19 -3
- package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
- package/build/renderable/ui/uitextbutton.d.ts +30 -1
- package/build/renderable/ui/uitextbutton.d.ts.map +1 -1
- package/build/state/state.d.ts.map +1 -1
- package/build/system/bootstrap.d.ts.map +1 -1
- package/build/system/legacy_pool.d.ts +24 -4
- package/build/system/legacy_pool.d.ts.map +1 -1
- package/build/system/pool.d.ts +15 -8
- package/build/system/pool.d.ts.map +1 -1
- package/build/tweens/tween.d.ts +50 -3
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +34 -23
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/effects/blendEffect.d.ts +0 -1
- package/build/video/effects/bloom.d.ts +72 -0
- package/build/video/effects/bloom.d.ts.map +1 -0
- package/build/video/effects/blur.d.ts +3 -2
- package/build/video/effects/blur.d.ts.map +1 -1
- package/build/video/effects/chromaticAberration.d.ts +3 -2
- package/build/video/effects/chromaticAberration.d.ts.map +1 -1
- package/build/video/effects/colorMatrix.d.ts +3 -2
- package/build/video/effects/colorMatrix.d.ts.map +1 -1
- package/build/video/effects/desaturate.d.ts +10 -2
- package/build/video/effects/desaturate.d.ts.map +1 -1
- package/build/video/effects/dissolve.d.ts +3 -2
- package/build/video/effects/dissolve.d.ts.map +1 -1
- package/build/video/effects/dropShadow.d.ts +3 -2
- package/build/video/effects/dropShadow.d.ts.map +1 -1
- package/build/video/effects/flash.d.ts +3 -2
- package/build/video/effects/flash.d.ts.map +1 -1
- package/build/video/effects/glow.d.ts +3 -2
- package/build/video/effects/glow.d.ts.map +1 -1
- package/build/video/effects/hologram.d.ts +3 -2
- package/build/video/effects/hologram.d.ts.map +1 -1
- package/build/video/effects/invert.d.ts +10 -2
- package/build/video/effects/invert.d.ts.map +1 -1
- package/build/video/effects/outline.d.ts +3 -2
- package/build/video/effects/outline.d.ts.map +1 -1
- package/build/video/effects/pixelate.d.ts +3 -2
- package/build/video/effects/pixelate.d.ts.map +1 -1
- package/build/video/effects/radialGradient.d.ts +8 -3
- package/build/video/effects/radialGradient.d.ts.map +1 -1
- package/build/video/effects/scanline.d.ts +3 -2
- package/build/video/effects/scanline.d.ts.map +1 -1
- package/build/video/effects/sepia.d.ts +10 -2
- package/build/video/effects/sepia.d.ts.map +1 -1
- package/build/video/effects/shadereffect.d.ts +10 -4
- package/build/video/effects/shadereffect.d.ts.map +1 -1
- package/build/video/effects/shine.d.ts +3 -2
- package/build/video/effects/shine.d.ts.map +1 -1
- package/build/video/effects/tintPulse.d.ts +3 -7
- package/build/video/effects/tintPulse.d.ts.map +1 -1
- package/build/video/effects/tonemap.d.ts +121 -0
- package/build/video/effects/tonemap.d.ts.map +1 -0
- package/build/video/effects/vignette.d.ts +3 -2
- package/build/video/effects/vignette.d.ts.map +1 -1
- package/build/video/effects/wave.d.ts +3 -7
- package/build/video/effects/wave.d.ts.map +1 -1
- package/build/video/gpu/batcher.d.ts +8 -2
- package/build/video/gpu/batcher.d.ts.map +1 -1
- package/build/video/gpu/vertexformat.d.ts +26 -0
- package/build/video/gpu/vertexformat.d.ts.map +1 -1
- package/build/video/gradient.d.ts +1 -1
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts +111 -7
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/renderstate.d.ts +2 -0
- package/build/video/renderstate.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +3 -4
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +0 -1
- package/build/video/rendertarget/rendertarget.d.ts +12 -5
- package/build/video/rendertarget/rendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webglrendertarget.d.ts +0 -1
- package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webgpurendertarget.d.ts +24 -14
- package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
- package/build/video/texture/atlas.d.ts +2 -1
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +1 -3
- package/build/video/texture/frametexture.d.ts +0 -1
- package/build/video/texture/frametexture.d.ts.map +1 -1
- package/build/video/texture/noise_texture2d.d.ts +1 -0
- package/build/video/texture/noise_texture2d.d.ts.map +1 -1
- package/build/video/texture/texture2d.d.ts +6 -0
- package/build/video/texture/texture2d.d.ts.map +1 -1
- package/build/video/utils/autodetect.d.ts +0 -2
- package/build/video/webgl/batchers/batcher.d.ts +0 -9
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +2 -0
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +4 -2
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +0 -3
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts +4 -0
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +0 -1
- package/build/video/webgl/buffer/retained_geometry.d.ts +0 -1
- package/build/video/webgl/glshader.d.ts +5 -3
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +0 -4
- package/build/video/webgl/texture/store.d.ts +0 -1
- package/build/video/webgl/webgl_renderer.d.ts +63 -24
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/mesh_batcher.d.ts +0 -3
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/quad_batcher.d.ts +0 -2
- package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts +0 -2
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -1
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +0 -2
- package/build/video/webgpu/texture/frametexture.d.ts +0 -2
- package/build/video/webgpu/texture/frametexture.d.ts.map +1 -1
- package/build/video/webgpu/texture/store.d.ts +0 -1
- package/build/video/webgpu/webgpu_renderer.d.ts +7 -75
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +2 -2
- package/skills/AGENTS.md +1 -1
- package/skills/melonjs/SKILL.md +2 -0
- package/skills/melonjs-3d/SKILL.md +454 -22
- package/skills/melonjs-3d-assets/SKILL.md +111 -10
- package/skills/melonjs-audio/SKILL.md +229 -8
- package/skills/melonjs-camera-and-drawing/SKILL.md +127 -1
- package/skills/melonjs-display-and-scaling/SKILL.md +273 -0
- package/skills/melonjs-effects-and-shaders/SKILL.md +341 -29
- package/skills/melonjs-events/SKILL.md +8 -6
- package/skills/melonjs-input/SKILL.md +147 -7
- package/skills/melonjs-math/SKILL.md +313 -0
- package/skills/melonjs-particles-and-trails/SKILL.md +189 -13
- package/skills/melonjs-performance/SKILL.md +131 -23
- package/skills/melonjs-physics/SKILL.md +103 -28
- package/skills/melonjs-renderables/SKILL.md +8 -2
- package/skills/melonjs-scenes-and-state/SKILL.md +134 -3
- package/skills/melonjs-sprites-and-animation/SKILL.md +9 -4
- package/skills/melonjs-tilemaps/SKILL.md +40 -12
- package/skills/melonjs-ui-and-text/SKILL.md +546 -7
- package/build/level/gltf/srgb.d.ts +0 -20
- package/build/level/gltf/srgb.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: melonjs-renderables
|
|
3
|
-
description: "Use this skill when subclassing Renderable, writing a custom draw() method, handling pointer or click events on game objects, applying post effects and shaders, or controlling draw order. Covers the pos-relative draw contract, isKinematic and input, addPostEffect vs the deprecated shader property, and z-ordering. Triggers on: Renderable, extends Renderable, draw(, update(, isKinematic, pointerEvent, registerPointerEvent, onClick, addPostEffect, removePostEffect, ShaderEffect, addChild, z-order, anchorPoint, floating."
|
|
3
|
+
description: "Use this skill when subclassing Renderable, writing a custom draw() method, handling pointer or click events on game objects, applying post effects and shaders, or controlling draw order. Covers the pos-relative draw contract, isKinematic and input, addPostEffect vs the deprecated shader property, and z-ordering. Triggers on: Tween, easing, animate, Renderable, extends Renderable, draw(, update(, isKinematic, pointerEvent, registerPointerEvent, onClick, addPostEffect, removePostEffect, ShaderEffect, addChild, z-order, anchorPoint, floating."
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -184,6 +184,11 @@ v.set(10, 20, v.z); // keep it
|
|
|
184
184
|
`pos` is an `ObservableVector3d`, whose `set(x = 0, y = 0, z = 0)` does the same
|
|
185
185
|
— so `this.pos.set(x, y)` wipes the object's depth.
|
|
186
186
|
|
|
187
|
+
`Renderable#setPosition(x, y, z?)` is the renderable-level form and does not:
|
|
188
|
+
omit `z` and the depth is left exactly as it was. Reach for it whenever you
|
|
189
|
+
are moving an object rather than editing a vector, and keep `v.set(x, y, v.z)`
|
|
190
|
+
for the vector itself.
|
|
191
|
+
|
|
187
192
|
## 7. A settings key the class never reads is silently ignored
|
|
188
193
|
|
|
189
194
|
A settings object is a plain literal: nothing rejects a key, so a name that
|
|
@@ -279,11 +284,12 @@ Hand-rolled equivalents miss the batching and the multi-backend support.
|
|
|
279
284
|
| off-screen object never ticks | `update()` is gated on `inViewport` — set `alwaysUpdate = true` |
|
|
280
285
|
| custom draw offset by half the size | centred `anchorPoint` default not zeroed |
|
|
281
286
|
| spatial query never finds an object | `isKinematic` left `true` — not in the broadphase |
|
|
282
|
-
| `z` unexpectedly 0 after a `set` | `Vector3d.set(x, y)` defaults `z` to 0 |
|
|
287
|
+
| `z` unexpectedly 0 after a `set` | `Vector3d.set(x, y)` defaults `z` to 0 — `setPosition(x, y)` on the renderable leaves the depth alone |
|
|
283
288
|
| a settings option appears to do nothing | the class never reads that key — see section 7 |
|
|
284
289
|
| `isRenderable = false` did not hide the object | it gates bounds, not drawing — use `alpha` |
|
|
285
290
|
|
|
286
291
|
## Related skills
|
|
292
|
+
- `melonjs-scenes-and-state` — `Tween` and the easing families, for animating any of this
|
|
287
293
|
|
|
288
294
|
- `melonjs-getting-started` — Application lifecycle and the scene graph
|
|
289
295
|
- `melonjs-20-migration` — the deprecated `shader` property and other pre-20 APIs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: melonjs-scenes-and-state
|
|
3
|
-
description: "Use this skill for scene structure and game flow in melonJS — Stage subclasses, the state manager, transitions, pausing, the update loop, timers and tweens. Covers onResetEvent versus the constructor, state.set before state.change, the camera and world lifecycle per stage, and pause-aware timing. Triggers on: Stage, state, state.set, state.change, state.transition, state.pause, onResetEvent, onDestroyEvent, onActivateEvent, onDeactivateEvent, PLAY, MENU, LOADING, update loop, GAME_UPDATE, timer, setTimeout, setInterval, Tween, freeze."
|
|
3
|
+
description: "Use this skill for scene structure and game flow in melonJS — Stage subclasses, the state manager, transitions, pausing, the update loop, timers and tweens. Covers onResetEvent versus the constructor, state.set before state.change, the camera and world lifecycle per stage, and pause-aware timing. Triggers on: Tween, easing, fade out, flash, pulse, punch, shrink back, ease in, ease out, animate over time, countdown in update, Stage, state, state.set, state.change, state.transition, state.pause, onResetEvent, onDestroyEvent, onActivateEvent, onDeactivateEvent, PLAY, MENU, LOADING, update loop, GAME_UPDATE, timer, setTimeout, setInterval, Tween, freeze."
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -165,6 +165,18 @@ Returning nothing is falsy and the object can appear frozen while its state move
|
|
|
165
165
|
`dt` is milliseconds since the last frame and is the right basis for motion —
|
|
166
166
|
the engine already paces it. Do not reach for `performance.now()`.
|
|
167
167
|
|
|
168
|
+
**Smooth a value toward a target with `math.damp`, not with `lerp` per
|
|
169
|
+
frame.** `lerp(current, target, 0.1)` once per frame moves further on a slow
|
|
170
|
+
frame than on a fast one, so the feel drifts with the frame rate:
|
|
171
|
+
|
|
172
|
+
```js
|
|
173
|
+
this.speed = math.damp(this.speed, targetSpeed, 5, dt / 1000);
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`damp(current, target, lambda, dt)` takes SECONDS, so divide `dt`. Higher
|
|
177
|
+
`lambda` converges faster. See `melonjs-camera-and-drawing` for the camera's
|
|
178
|
+
own `follow()` damping, which is already frame-rate independent for you.
|
|
179
|
+
|
|
168
180
|
A common idiom for a per-frame game controller with nothing to draw is a
|
|
169
181
|
`Renderable(0, 0, 1, 1)` with `alwaysUpdate = true` and an empty `draw()`.
|
|
170
182
|
|
|
@@ -182,6 +194,17 @@ timer.clearInterval(id); // in the Stage's onDestroyEvent
|
|
|
182
194
|
`onActivateEvent` / `onDeactivateEvent` on a stage. Those two are `Renderable`
|
|
183
195
|
hooks; put per-renderable teardown there instead.
|
|
184
196
|
|
|
197
|
+
**The outgoing stage is destroyed before the incoming one is reset.** That
|
|
198
|
+
ordering is what makes "each stage owns what it started" work: a scene can
|
|
199
|
+
release a resource in `onDestroyEvent` and the next scene can claim the same
|
|
200
|
+
one in `onResetEvent` without the teardown arriving late and undoing it.
|
|
201
|
+
|
|
202
|
+
What a stage starts, it must end: `input.registerPointerEvent` regions,
|
|
203
|
+
`event.on` subscriptions and running `Tween`s all outlive the stage that made
|
|
204
|
+
them. Music is the exception rather than the rule, since `audio.playTrack()`
|
|
205
|
+
stops the track it replaces, so `stopTrack()` in `onDestroyEvent` is only
|
|
206
|
+
needed where the next screen has no music of its own.
|
|
207
|
+
|
|
185
208
|
Engine timers are **pause-aware**. `window.setTimeout` keeps firing while the
|
|
186
209
|
game is paused, which produces enemies spawning behind a pause menu. Pass
|
|
187
210
|
`false` as the third argument — `timer.setInterval(fn, 500, false)` — for one
|
|
@@ -191,10 +214,63 @@ countdown that should not freeze needs. (That argument was ignored by
|
|
|
191
214
|
|
|
192
215
|
## Tweens
|
|
193
216
|
|
|
217
|
+
### You are hand-rolling a tween if you write this
|
|
218
|
+
|
|
219
|
+
The shape, in any of its spellings. If you are adding a field that counts
|
|
220
|
+
milliseconds and dividing it by a constant to get a `0..1`, stop:
|
|
221
|
+
|
|
194
222
|
```js
|
|
195
|
-
|
|
223
|
+
// ✗ a tween, written out longhand
|
|
224
|
+
private flashMs = 0;
|
|
225
|
+
// ... in update(dt)
|
|
226
|
+
if (this.flashMs > 0) {
|
|
227
|
+
this.flashMs -= dt;
|
|
228
|
+
const k = this.flashMs / FLASH_MS; // ← the 0..1
|
|
229
|
+
effect.setUniform("uIntensity", k * k); // ← and a curve, by hand
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
// ✓ the same thing
|
|
235
|
+
const driver = { k: 1 };
|
|
236
|
+
new Tween(driver)
|
|
237
|
+
.to({ k: 0 }, { duration: FLASH_MS })
|
|
238
|
+
.easing(Tween.Easing.Quadratic.In) // the curve, named
|
|
239
|
+
.onUpdate(() => effect.setUniform("uIntensity", driver.k))
|
|
240
|
+
.start();
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
The tells, any one of which is enough: a `*Ms` or `*Age` field that only
|
|
244
|
+
`update()` touches; a division by a `*_MS` constant; `k * k`, `(1 - k) ** 2` or
|
|
245
|
+
`** 1.4` written inline, which is an easing curve spelled by hand; an
|
|
246
|
+
`if (x <= 0)` arm that exists only to clean up at the end, which is
|
|
247
|
+
`onComplete`; a second timer counting the same duration to chain what happens
|
|
248
|
+
next, which is `delay`.
|
|
249
|
+
|
|
250
|
+
It matters beyond tidiness: a hand-rolled fade needs something to tick it, and
|
|
251
|
+
an effect that is NOT a renderable (one living on the camera, say) has nothing
|
|
252
|
+
that will. That forces an `update(dt)` method and a call site in the game loop
|
|
253
|
+
whose only job is to drive the fade. A tween updates itself, so both disappear.
|
|
254
|
+
|
|
255
|
+
### When NOT to reach for one
|
|
256
|
+
|
|
257
|
+
Four shapes that look similar and are not tweens:
|
|
258
|
+
|
|
259
|
+
| shape | what it is | use |
|
|
260
|
+
| --- | --- | --- |
|
|
261
|
+
| approaching a value that keeps MOVING | a follow, not an animation | `math.damp` |
|
|
262
|
+
| a loop that never ends | oscillation | a sine of your own clock |
|
|
263
|
+
| a gate: cooldown, spawn interval, invulnerability window | a timer, nothing is interpolated | a plain countdown |
|
|
264
|
+
| the same effect on dozens of live objects | per-instance churn | a hand-rolled countdown really is cheaper |
|
|
196
265
|
|
|
197
|
-
|
|
266
|
+
The rule in one line: **fixed duration, known endpoint, one-shot, few
|
|
267
|
+
instances.** All four, or it is not a tween.
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
```js
|
|
271
|
+
import { getPool, Tween } from "melonjs";
|
|
272
|
+
|
|
273
|
+
const t = getPool("tween").get(sprite.pos) // typed pool, release when done
|
|
198
274
|
.to({ x: 300 }, { duration: 500 }) // options object, not a number
|
|
199
275
|
.easing(Tween.Easing.Quadratic.Out)
|
|
200
276
|
.onComplete(() => { /* … */ })
|
|
@@ -216,6 +292,61 @@ Four traps:
|
|
|
216
292
|
- **Stop a tween before destroying its target**, or `onUpdate` fires against a
|
|
217
293
|
dead renderable.
|
|
218
294
|
|
|
295
|
+
**To animate something that is not a property, tween a holder and push the
|
|
296
|
+
value in `onUpdate`.** A shader uniform and a light's intensity are both set
|
|
297
|
+
through a method, so there is nothing for `to()` to interpolate directly. The
|
|
298
|
+
callback is invoked with the tweened object as `this` and the eased progress
|
|
299
|
+
`0..1` as its argument:
|
|
300
|
+
|
|
301
|
+
```js
|
|
302
|
+
const fade = { level: 1 };
|
|
303
|
+
getPool("tween").get(fade)
|
|
304
|
+
.to({ level: 0 }, { duration: 400 })
|
|
305
|
+
.easing(Tween.Easing.Quadratic.Out)
|
|
306
|
+
.onUpdate(function () {
|
|
307
|
+
effect.setUniform("uIntensity", this.level);
|
|
308
|
+
muzzleLight.intensity = this.level * 3;
|
|
309
|
+
})
|
|
310
|
+
.start();
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Use a `function`, not an arrow, if you want `this` to be the tweened object;
|
|
314
|
+
an arrow keeps the enclosing `this` and you read the holder by name instead.
|
|
315
|
+
For a handful of pooled objects a hand-rolled countdown in `update()` is
|
|
316
|
+
cheaper than a `Tween` each — this is the right tool for one-off effects, not
|
|
317
|
+
for every particle.
|
|
318
|
+
|
|
319
|
+
### Pick the easing, not just the duration
|
|
320
|
+
|
|
321
|
+
Eleven families, each with `In`, `Out` and `InOut`. `Out` is what most UI
|
|
322
|
+
wants: the value arrives decisively instead of creeping in. The two worth
|
|
323
|
+
knowing by name beyond the power curves:
|
|
324
|
+
|
|
325
|
+
| family | what it does |
|
|
326
|
+
| --- | --- |
|
|
327
|
+
| `Back` | **overshoots past the target and settles back**, which is impact: a stamp, a button press, anything that should LAND rather than arrive |
|
|
328
|
+
| `Bounce` | lands and bounces, for something dropping onto a surface |
|
|
329
|
+
|
|
330
|
+
```js
|
|
331
|
+
// a stamp: scale falls to 1 and springs through it
|
|
332
|
+
const driver = { scale: 5 };
|
|
333
|
+
new Tween(driver)
|
|
334
|
+
.to({ scale: 1 }, { duration: 420 })
|
|
335
|
+
.easing(Tween.Easing.Back.Out)
|
|
336
|
+
.onUpdate(() => { label.currentTransform.identity(); label.scale(driver.scale); })
|
|
337
|
+
.onComplete(() => camera.shake(12, 400)) // the thump, when it truly lands
|
|
338
|
+
.start();
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
`Back` and `Elastic` **leave the range** between your start and end, so clamp
|
|
342
|
+
anything that cannot take it, an opacity or a colour channel above all. The
|
|
343
|
+
overshoot follows the direction of travel: a value tweened DOWN overshoots
|
|
344
|
+
below its target.
|
|
345
|
+
|
|
346
|
+
Reach for `onComplete` for anything that must happen on arrival, rather than a
|
|
347
|
+
second timer counting the same duration. `delay` in the `to()` options chains
|
|
348
|
+
the next one without a timer either.
|
|
349
|
+
|
|
219
350
|
## Guard teardown-adjacent callbacks
|
|
220
351
|
|
|
221
352
|
Callbacks can fire while a stage is being torn down, when the current state is
|
|
@@ -103,7 +103,7 @@ Packing into one atlas keeps everything on a single binding.
|
|
|
103
103
|
## Visual properties
|
|
104
104
|
|
|
105
105
|
```js
|
|
106
|
-
sprite.
|
|
106
|
+
sprite.setTint("#ff8000"); // multiply tint
|
|
107
107
|
sprite.alpha = 0.5;
|
|
108
108
|
sprite.flipX(true); // mirror horizontally
|
|
109
109
|
sprite.flipY(true);
|
|
@@ -141,9 +141,14 @@ The insets default to a quarter of the frame.
|
|
|
141
141
|
Frequently spawned sprites should be pooled:
|
|
142
142
|
|
|
143
143
|
```js
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
import { createPool } from "melonjs";
|
|
145
|
+
|
|
146
|
+
const bulletPool = createPool((x, y) => { // me.pool is deprecated
|
|
147
|
+
const instance = new Bullet(x, y);
|
|
148
|
+
return { instance, reset: (x, y) => instance.onResetEvent(x, y) };
|
|
149
|
+
});
|
|
150
|
+
const b = bulletPool.get(x, y); // new Bullet(x, y), or reset(x, y) on a reused one
|
|
151
|
+
world.removeChild(b); // returns it to bulletPool automatically
|
|
147
152
|
```
|
|
148
153
|
|
|
149
154
|
Two consequences:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: melonjs-tilemaps
|
|
3
|
-
description: "Use this skill for Tiled maps in melonJS — loading TMX/TSX levels, spawning entities from Tiled objects, collision shapes authored in Tiled, isometric and hexagonal maps, and image layers. Covers the pool.register name contract, camera bounds, compressed maps needing the inflate plugin, and the level director API. Triggers on: Tiled, TMX, TSX, tilemap, level.load, level.load async, await level.load, tileset, ImageLayer, isometric, hexagonal, staggered, pool.register, Collectable, Trigger, object layer, collision layer, parallax."
|
|
3
|
+
description: "Use this skill for Tiled maps in melonJS — loading TMX/TSX levels, spawning entities from Tiled objects, collision shapes authored in Tiled, isometric and hexagonal maps, and image layers. Covers registerTiledObjectClass and the pool.register name contract, camera bounds, compressed maps needing the inflate plugin, and the level director API. Triggers on: Tiled, TMX, TSX, tilemap, level.load, level.load async, await level.load, tileset, ImageLayer, isometric, hexagonal, staggered, pool.register, Collectable, Trigger, object layer, collision layer, parallax, registerTiledObjectClass, registerTiledObjectFactory."
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -38,6 +38,10 @@ also skip `src` and pass the map inline via `data` (with `format: "json"` or
|
|
|
38
38
|
`level <id> not found` for an unknown id — synchronously, in both forms, because
|
|
39
39
|
that is a typo rather than a load failure.
|
|
40
40
|
|
|
41
|
+
Those `game.` defaults are the engine's own, and `game` is whichever
|
|
42
|
+
`Application` finished `init()` last. **Pass `container` explicitly** from a
|
|
43
|
+
`Stage`, which has the right one: `level.load("map", { container: this.app.world })`.
|
|
44
|
+
|
|
41
45
|
**`level.load` is deferred while the game loop is running.** It calls
|
|
42
46
|
`state.stop()` and finishes the load on a timer, after the current frame, so by
|
|
43
47
|
default it returns `true` before anything is in the world. Two ways to sequence
|
|
@@ -72,19 +76,30 @@ Tiled **class**, then its **name**, then the structural fallbacks `"text"`,
|
|
|
72
76
|
`"tile"` and `"shape"`.
|
|
73
77
|
|
|
74
78
|
```js
|
|
75
|
-
|
|
79
|
+
import { registerTiledObjectClass, registerTiledObjectFactory } from "melonjs";
|
|
80
|
+
|
|
81
|
+
registerTiledObjectClass("Enemy", Enemy); // ← matches Tiled class OR name
|
|
82
|
+
registerTiledObjectFactory("Spine", (settings, map) => { /* → Renderable */ });
|
|
76
83
|
level.load("map1");
|
|
77
84
|
```
|
|
78
85
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
`pool.autoRegisterTiled = false`. The dedicated entry points are:
|
|
86
|
+
These are the entry points to use. The registry is Tiled's own, held by the
|
|
87
|
+
object factory, and has nothing to do with object pooling.
|
|
82
88
|
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
`pool.register(className, classObj)` **also** works and registers a Tiled
|
|
90
|
+
factory as a side effect, under the name and again under an `me.`-prefixed
|
|
91
|
+
alias, unless you set `pool.autoRegisterTiled = false`. That is the older
|
|
92
|
+
spelling, kept working for maps and games written against it, and it now
|
|
93
|
+
prints a one-off deprecation notice: `me.pool` is deprecated since 18.0.0.
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
Its third argument no longer buys anything here. It used to make Tiled
|
|
96
|
+
objects recyclable; they are constructed directly now, and the container
|
|
97
|
+
returns children to typed pools rather than to the name-keyed one. To pool a
|
|
98
|
+
class you spawn constantly, give it a `createPool` and register it for Tiled
|
|
99
|
+
separately:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
registerTiledObjectClass("mainPlayer", PlayerEntity);
|
|
88
103
|
```
|
|
89
104
|
|
|
90
105
|
Register **before** loading. With no match the object falls through to the
|
|
@@ -94,11 +109,24 @@ not error, it just has none of your behaviour.
|
|
|
94
109
|
`registerTiledObjectClass` **throws** if you register a *different* constructor
|
|
95
110
|
under a name already taken (re-registering the same one is a no-op).
|
|
96
111
|
`registerTiledObjectFactory` overwrites and only `console.warn`s, so it is the
|
|
97
|
-
one to use for
|
|
112
|
+
one to use for replacing something already registered.
|
|
113
|
+
|
|
114
|
+
**Overriding a built-in name always works.** The engine's own classes are
|
|
115
|
+
DEFAULTS: they fill a name nothing else has claimed, and yours takes it over
|
|
116
|
+
whenever you register, before or after a map has loaded.
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
registerTiledObjectClass("Trigger", MyTrigger); // whenever you like
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The throw is for a clash between two of *your* classes under one name. For
|
|
123
|
+
that case `registerTiledObjectFactory` overwrites and only warns.
|
|
98
124
|
|
|
99
125
|
melonJS pre-registers `Renderable`, `Sprite`, `NineSliceSprite`, `Text`,
|
|
100
|
-
`BitmapText`, `ImageLayer`, `ColorLayer`, `Light2d`, `Collectable
|
|
101
|
-
as Tiled classes, so `Collectable` and `Trigger` work out of the
|
|
126
|
+
`BitmapText`, `ImageLayer`, `ColorLayer`, `Light2d`, `Collectable`, `Trigger`
|
|
127
|
+
and `Entity` as Tiled classes, so `Collectable` and `Trigger` work out of the
|
|
128
|
+
box. Each is registered under its `me.`-prefixed alias as well, so a map
|
|
129
|
+
authored against melonJS 1.x finds them where it looks.
|
|
102
130
|
|
|
103
131
|
A `Trigger` forwards a **fixed list** of settings to `level.load()` — not
|
|
104
132
|
whatever you pass it. Today that list is `container`, `onLoaded`, `flatten`,
|