diff --git a/package.json b/package.json index ff425be..a37b3cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "momentumengine", - "version": "0.7.0", + "version": "0.8.0", "description": "An ES6 game and animation engine.", "main": "src/es6.js", "repository": { @@ -15,18 +15,17 @@ "author": "Nathan Kunicki ", "license": "MIT", "engines": { - "node": "^4.2.3" + "node": "^7.6.0" }, "dependencies": { - "babel-core": "6.7.4", - "babel-loader": "6.2.4", - "babel-plugin-transform-runtime": "6.6.0", - "babel-preset-es2015": "6.6.0", - "babel-preset-stage-0": "6.5.0", - "babel-runtime": "6.6.1", + "babel-core": "6.23.1", + "babel-loader": "6.3.2", + "babel-plugin-transform-runtime": "6.23.0", + "babel-preset-es2015": "6.22.0", + "babel-preset-stage-0": "6.22.0", "gulp": "3.9.1", - "gulp-jsdoc3": "0.2.1", - "gulp-util": "3.0.7", - "webpack": "1.12.14" + "gulp-jsdoc3": "1.0.1", + "gulp-util": "3.0.8", + "webpack": "2.2.1" } } diff --git a/src/classes/entity.js b/src/classes/entity.js index 72f966d..8b13e74 100644 --- a/src/classes/entity.js +++ b/src/classes/entity.js @@ -47,7 +47,13 @@ class Entity { } set left (val) { - return this.pos.x = val; + let res = (this.pos.x = val); + if (this._parent) { + this._relativePos.x = this.pos.x + this._parent.relativeLeft; + } else { + this._relativePos.x = this.pos.x; + } + return res; } @@ -59,7 +65,13 @@ class Entity { } set top (val) { - return this.pos.y = val; + let res = (this.pos.y = val); + if (this._parent) { + this._relativePos.y = this.pos.y + this._parent.relativeTop; + } else { + this._relativePos.y = this.pos.y; + } + return res; } diff --git a/src/classes/path.js b/src/classes/path.js index c26a8ba..364e2b6 100644 --- a/src/classes/path.js +++ b/src/classes/path.js @@ -33,10 +33,10 @@ class Path extends Entity { ctx.strokeStyle = this.color.toString(); ctx.beginPath(); - ctx.moveTo(this.relativeLeft, this.relativeTop); + ctx.moveTo(this._scaleForLeft(this.relativeLeft), this._scaleForTop(this.relativeTop)); for (let coord in this.coords) { - ctx.lineTo(this.relativeLeft + this.coords[coord].x, this.relativeTop + this.coords[coord].y); + ctx.lineTo(this._scaleForWidth(this.relativeLeft + this.coords[coord].x), this._scaleForHeight(this.relativeTop + this.coords[coord].y)); } //ctx.closePath();