From 3020e3b8cf7172fd9911b54ce3575d8b0b8d5ab9 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Fri, 14 Oct 2016 08:59:24 +0100 Subject: [PATCH] Updating core objects. --- src/gameobjects/BaseGameObject.js | 44 +++++++++++++++++++++++++++++++ src/gameobjects/GameObject.js | 29 ++++++++++++++++++++ src/gameobjects/sprite/Sprite.js | 16 ++++++----- 3 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 src/gameobjects/BaseGameObject.js diff --git a/src/gameobjects/BaseGameObject.js b/src/gameobjects/BaseGameObject.js new file mode 100644 index 000000000..815bb1cb2 --- /dev/null +++ b/src/gameobjects/BaseGameObject.js @@ -0,0 +1,44 @@ +/** +* @author Richard Davey +* @copyright 2016 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +Phaser.GameObject = function (game) +{ + this.game = game; + + this.name = ''; + + this.parent = null; + + this.children = null; + + this.transform = null; +}; + +Phaser.GameObject.prototype.constructor = Phaser.GameObject; + +Phaser.GameObject.prototype = { + + preUpdate: function () + { + // NOOP + }, + + update: function () + { + // NOOP + }, + + postUpdate: function () + { + // NOOP + }, + + render: function () + { + // NOOP + } + +}; diff --git a/src/gameobjects/GameObject.js b/src/gameobjects/GameObject.js index 5eea80a38..815bb1cb2 100644 --- a/src/gameobjects/GameObject.js +++ b/src/gameobjects/GameObject.js @@ -8,8 +8,37 @@ Phaser.GameObject = function (game) { this.game = game; + this.name = ''; + + this.parent = null; + this.children = null; this.transform = null; +}; + +Phaser.GameObject.prototype.constructor = Phaser.GameObject; + +Phaser.GameObject.prototype = { + + preUpdate: function () + { + // NOOP + }, + + update: function () + { + // NOOP + }, + + postUpdate: function () + { + // NOOP + }, + + render: function () + { + // NOOP + } }; diff --git a/src/gameobjects/sprite/Sprite.js b/src/gameobjects/sprite/Sprite.js index cddff0d68..2fda88af3 100644 --- a/src/gameobjects/sprite/Sprite.js +++ b/src/gameobjects/sprite/Sprite.js @@ -55,10 +55,12 @@ Phaser.GameObject.Sprite = function (game, x, y, key, frame) this.data = new Phaser.Component.Data(this); + this.color = new Phaser.Component.Color(this); + // Temporary for now? - this.alpha = 1; - this.worldAlpha = 1; - this.blendMode = Phaser.blendModes.NORMAL; + // this.alpha = 1; + // this.worldAlpha = 1; + // this.blendMode = Phaser.blendModes.NORMAL; this.scaleMode = Phaser.scaleModes.DEFAULT; this.exists = true; }; @@ -74,10 +76,10 @@ Phaser.GameObject.Sprite.prototype.constructor = Phaser.GameObject.Sprite; */ Phaser.GameObject.Sprite.prototype.preUpdate = function () { - if (this.parent) - { - this.worldAlpha = this.alpha * this.parent.worldAlpha; - } + // if (this.parent) + // { + // this.worldAlpha = this.alpha * this.parent.worldAlpha; + // } this.children.preUpdate(); };