diff --git a/.travis.yml b/.travis.yml index c163c359..6ef399b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,4 +16,4 @@ deploy: keep_history: true local_dir: docs # on: - # branch: master \ No newline at end of file + # branch: main \ No newline at end of file diff --git a/src/gameObject.js b/src/gameObject.js index c65aff21..0672af02 100644 --- a/src/gameObject.js +++ b/src/gameObject.js @@ -360,6 +360,34 @@ class GameObject { set viewY(value) { return; } + + // ifdef GAMEOBJECT_GROUP + get sx() { + return this._sx; + } + + get sy() { + return this._sy; + } + + set sx(value) { + let diff = value - this._sx; + this.children.map(child => { + child.sx += diff; + }); + + this._sx = value; + } + + set sy(value) { + let diff = value - this._sy; + this.children.map(child => { + child.sy += diff; + }); + + this._sy = value; + } + // @endif // @endif // @ifdef GAMEOBJECT_TTL @@ -401,7 +429,7 @@ class GameObject { * @function addChild * * @param {GameObject} child - Object to add as a child. - * @param {Object} options - Options for adding the child. + * @param {Object} [options] - Options for adding the child. * @param {Boolean} [options.absolute=false] - If set the true, the x/y position of the child is treated as an absolute position in the world rather than being relative to the x/y position of the parent. * * @example diff --git a/test/unit/button.spec.js b/test/unit/button.spec.js index 9e0acb7c..d70b0ec4 100644 --- a/test/unit/button.spec.js +++ b/test/unit/button.spec.js @@ -16,7 +16,9 @@ describe('button', () => { let button; beforeEach(() => { button = Button({ - text: 'Hello' + text: { + text: 'Hello' + } }); }); @@ -31,17 +33,20 @@ describe('button', () => { it('should setup basic properties', () => { button = Button({ - text: 'Hello', - font: '32px Arial', - width: 100, - color: 'black' + text: { + text: 'Hello', + font: '32px Arial', + width: 100, + color: 'black' + } }); - expect(button.width).to.equal(100); - expect(button.height).to.equal(32); - expect(button.font).to.equal('32px Arial'); - expect(button.text).to.equal('Hello'); - expect(button.color).to.equal('black'); + expect(button.textNode).to.exist; + expect(button.textNode.width).to.equal(100); + expect(button.textNode.height).to.equal(32); + expect(button.textNode.font).to.equal('32px Arial'); + expect(button.textNode.text).to.equal('Hello'); + expect(button.textNode.color).to.equal('black'); }); it('should create a DOM node and add it to the page', () => {