From 90a2f71e0b29b4bf938569313e6849571b48b589 Mon Sep 17 00:00:00 2001 From: Active Date: Thu, 14 Nov 2024 11:51:03 -0600 Subject: [PATCH] hotfix: fixes when adding instance to layer not recieving config --- package.json | 2 +- src/layer.mjs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f126609..d8dc3e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "parallax", - "version": "1.1.0", + "version": "1.1.1", "description": "A parallax module that will enable effortless integration of depth effects into your game.", "main": "src/parallax.mjs", "scripts": { diff --git a/src/layer.mjs b/src/layer.mjs index beaa3a7..5561010 100644 --- a/src/layer.mjs +++ b/src/layer.mjs @@ -138,8 +138,15 @@ export class Layer { * @prop {boolean} pConfig.loop - Whether this instance will be treated as a background and loop seamlessly. */ add(pInstance, pConfig) { + if (this.config.instances.has(pInstance)) return; this.config.instances.add(pInstance); - Parallax.add(pInstance, pConfig); + const config = pConfig + ? pConfig + : { + x: this.config.horizontalSpeed, + y: this.config.verticalSpeed + } + Parallax.add(pInstance, config); } /** * Removes the instance from the parallax layer.