diff --git a/examples/assets/fonts/megadeth_tlb.png b/examples/assets/fonts/megadeth_tlb.png new file mode 100644 index 00000000..1f46ce76 Binary files /dev/null and b/examples/assets/fonts/megadeth_tlb.png differ diff --git a/examples/display/graphics.php b/examples/display/graphics.php new file mode 100644 index 00000000..3c89137c --- /dev/null +++ b/examples/display/graphics.php @@ -0,0 +1,83 @@ + + + + + diff --git a/src/gameobjects/Graphics.js b/src/gameobjects/Graphics.js index b26aa5c2..a28f45ff 100644 --- a/src/gameobjects/Graphics.js +++ b/src/gameobjects/Graphics.js @@ -1,124 +1,45 @@ Phaser.Graphics = function (game, x, y) { - // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all - this.exists = true; + PIXI.Graphics.call(this); - // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering - this.alive = true; - - this.group = null; - - this.name = ''; - - this.game = game; - - PIXI.DisplayObjectContainer.call(this); + Phaser.Sprite.call(this, game, x, y); this.type = Phaser.GRAPHICS; - this.position.x = x; - this.position.y = y; - - // Replaces the PIXI.Point with a slightly more flexible one - this.scale = new Phaser.Point(1, 1); - - // Influence of camera movement upon the position - this.scrollFactor = new Phaser.Point(1, 1); - - // A mini cache for storing all of the calculated values - this._cache = { - - dirty: false, - - // Transform cache - a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, - - // The previous calculated position inc. camera x/y and scrollFactor - x: -1, y: -1, - - // The actual scale values based on the worldTransform - scaleX: 1, scaleY: 1 - - }; - - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); - - this.renderable = true; - - /** - * The alpha of the fill of this graphics object - * - * @property fillAlpha - * @type Number - */ - this.fillAlpha = 1; - - /** - * The width of any lines drawn - * - * @property lineWidth - * @type Number - */ - this.lineWidth = 0; - - /** - * The color of any lines drawn - * - * @property lineColor - * @type String - */ - this.lineColor = "black"; - - /** - * Graphics data - * - * @property graphicsData - * @type Array - * @private - */ - this.graphicsData = []; - - /** - * Current path - * - * @property currentPath - * @type Object - * @private - */ - this.currentPath = {points:[]}; - }; -Phaser.Graphics.prototype = Phaser.Utils.extend(true, PIXI.Graphics.prototype, PIXI.DisplayObjectContainer.prototype, Phaser.Sprite.prototype); +Phaser.Graphics.prototype = Object.create( PIXI.Graphics.prototype ); Phaser.Graphics.prototype.constructor = Phaser.Graphics; +Phaser.Graphics.prototype = Phaser.Utils.extend(true, Phaser.Graphics.prototype, Phaser.Sprite.prototype); + // Add our own custom methods /** * Automatically called by World.update */ -Phaser.Graphics.prototype.update = function() { +Phaser.Graphics.prototype.OLDupdate = function() { - if (!this.exists) - { - return; - } + // if (!this.exists) + // { + // return; + // } - this._cache.dirty = false; + // this._cache.dirty = false; - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + // this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); + // this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); - if (this.position.x != this._cache.x || this.position.y != this._cache.y) - { - this.position.x = this._cache.x; - this.position.y = this._cache.y; - this._cache.dirty = true; - } + // if (this.position.x != this._cache.x || this.position.y != this._cache.y) + // { + // this.position.x = this._cache.x; + // this.position.y = this._cache.y; + // this._cache.dirty = true; + // } } +/* Object.defineProperty(Phaser.Graphics.prototype, 'angle', { get: function() { @@ -154,3 +75,5 @@ Object.defineProperty(Phaser.Graphics.prototype, 'y', { } }); + +*/ diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 9aee2e8f..ed08123e 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -87,13 +87,6 @@ Phaser.Utils = { return true; }, - - // deep, target, objects to copy to the target object - // This is a slightly modified version of jQuery.extend (http://api.jquery.com/jQuery.extend/) - // deep (boolean) - // target (object to add to) - // objects ... (objects to recurse and copy from) - /** * This is a slightly modified version of jQuery.extend (http://api.jquery.com/jQuery.extend/) * @method extend @@ -156,7 +149,7 @@ Phaser.Utils = { } // Never move original objects, clone them - target[name] = extend(deep, clone, copy); + target[name] = Phaser.Utils.extend(deep, clone, copy); // Don't bring in undefined values }