diff --git a/build/config.php b/build/config.php index 77ba03a8..59c48231 100644 --- a/build/config.php +++ b/build/config.php @@ -6,6 +6,41 @@ $path = '..'; } +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +*/ + echo << @@ -28,10 +63,7 @@ - - - @@ -56,33 +88,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/_site/view_full.html b/examples/_site/view_full.html index 6e1a2d57..33314ad8 100644 --- a/examples/_site/view_full.html +++ b/examples/_site/view_full.html @@ -17,48 +17,76 @@ - + - + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -66,10 +94,10 @@ + - @@ -106,10 +134,10 @@ - + @@ -151,8 +179,6 @@ - - @@ -163,7 +189,7 @@
- Phaser Version: 1.1.4 + Phaser Version: 1.2 New version:
diff --git a/examples/_site/view_lite.html b/examples/_site/view_lite.html index 0134e8ef..b7c6d0ae 100644 --- a/examples/_site/view_lite.html +++ b/examples/_site/view_lite.html @@ -10,55 +10,83 @@ - + - + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -66,9 +94,9 @@ + - @@ -106,10 +134,10 @@ - + @@ -151,7 +179,6 @@ - diff --git a/examples/assets/audio/protracker/shampoo.mod b/examples/assets/audio/protracker/shampoo.mod new file mode 100644 index 00000000..08ecbd54 Binary files /dev/null and b/examples/assets/audio/protracker/shampoo.mod differ diff --git a/examples/audio/protracker.js b/examples/audio/protracker.js index 4ca33bc9..eee16b19 100644 --- a/examples/audio/protracker.js +++ b/examples/audio/protracker.js @@ -10,6 +10,7 @@ function preload() { game.load.image('bg', 'assets/skies/sky2.png'); game.load.image('vulkaiser', 'assets/pics/vulkaiser_red.png'); + game.load.binary('shampoo', 'assets/audio/protracker/shampoo.mod', modLoaded, this); game.load.binary('macrocosm', 'assets/audio/protracker/macrocosm.mod', modLoaded, this); game.load.binary('impulse', 'assets/audio/protracker/act_of_impulse.mod', modLoaded, this); game.load.binary('enigma', 'assets/audio/protracker/enigma.mod', modLoaded, this); @@ -66,7 +67,7 @@ function create() { vu4.width = 0; module = new Protracker(); - module.buffer = game.cache.getBinary('macrocosm'); + module.buffer = game.cache.getBinary('shampoo'); module.parse(); module.play(); diff --git a/examples/groups/bring a group to top.js b/examples/groups/bring a group to top.js index 2365053c..687c07f2 100644 --- a/examples/groups/bring a group to top.js +++ b/examples/groups/bring a group to top.js @@ -31,7 +31,7 @@ function create() { // Now let's create some random sprites and enable them all for drag and 'bring to top' for (var i = 0; i < 10; i++) { - var tempSprite = game.add.sprite(game.stage.randomX, game.stage.randomY, 'atari1'); + var tempSprite = game.add.sprite(game.world.randomX, game.world.randomY, 'atari1'); tempSprite.name = 'atari' + i; tempSprite.input.start(i, true); @@ -41,7 +41,7 @@ function create() { // Sonics - var tempSprite=game.add.sprite(game.stage.randomX, game.stage.randomY, 'sonic'); + var tempSprite=game.add.sprite(game.world.randomX, game.world.randomY, 'sonic'); tempSprite.name = 'sonic' + i; tempSprite.input.start(10 + i, true); diff --git a/examples/index.html b/examples/index.html index 6f8c1fc5..779e9342 100644 --- a/examples/index.html +++ b/examples/index.html @@ -12,7 +12,7 @@
- Phaser Version: 1.1.4 + Phaser Version: 1.2 New version:
@@ -57,7 +57,7 @@
- © 2013 Photon Storm Ltd.
+ © 2014 Photon Storm Ltd.
All rights reserved.
diff --git a/examples/sideview.html b/examples/sideview.html index 3b2cfd4c..b601530a 100644 --- a/examples/sideview.html +++ b/examples/sideview.html @@ -19,7 +19,7 @@
diff --git a/examples/wip/pixi1.js b/examples/wip/pixi1.js index c4b3ebb0..a2c96b3a 100644 --- a/examples/wip/pixi1.js +++ b/examples/wip/pixi1.js @@ -26,6 +26,8 @@ function create() { game.input.onDown.add(tint, this); + game.add.tween(sprite).to({y: 500}, 3000, Phaser.Easing.Linear.None, true); + } function tint() { diff --git a/examples/wip/pixi2.js b/examples/wip/pixi2.js new file mode 100644 index 00000000..0c7faa5d --- /dev/null +++ b/examples/wip/pixi2.js @@ -0,0 +1,88 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png'); + game.load.image('snot', 'assets/pics/nslide_snot.png'); + game.load.image('atari1', 'assets/sprites/atari130xe.png'); + game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); + game.load.image('coke', 'assets/sprites/cokecan.png'); + game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png'); + +} + +var group1; +var group2; +var coke; +var disk; + +function create() { + + // Create a background image + game.add.sprite(0, 0, 'beast'); + + // Create a Group that will sit above the background image + group1 = game.add.group(); + + // Create a Group that will sit above Group 1 + group2 = game.add.group(); + + // Now let's create some random sprites and enable them all for drag and 'bring to top' + for (var i = 0; i < 10; i++) + { + var tempSprite = game.add.sprite(game.world.randomX, game.world.randomY, 'atari1'); + + tempSprite.name = 'atari' + i; + tempSprite.input.start(i, true); + tempSprite.input.enableDrag(false, true); + + group1.add(tempSprite); + + // Sonics + + var tempSprite=game.add.sprite(game.world.randomX, game.world.randomY, 'sonic'); + + tempSprite.name = 'sonic' + i; + tempSprite.input.start(10 + i, true); + tempSprite.input.enableDrag(false, true); + + group2.add(tempSprite); + } + + // Add 2 control sprites into each group - these cannot be dragged but should be bought to the top each time + coke = group1.create(100, 100, 'coke'); + disk = group2.create(400, 300, 'disk'); + + // Create a foreground image - everything should appear behind this, even when dragged + var snot = game.add.sprite(game.world.centerX, game.world.height, 'snot'); + snot.anchor.setTo(0.5, 1); + + // You can click and drag any sprite but Sonic sprites should always appear above the Atari sprites + // and both types of sprite should only ever appear above the background and behind the + + game.input.onDown.add(wibble, this); + +} + +function wibble(p) { + console.log(p); +} + +function update() { + + if (game.input.keyboard.justReleased(Phaser.Keyboard.ONE)) + { + coke.bringToTop(); + } + + if (game.input.keyboard.justReleased(Phaser.Keyboard.TWO)) + { + disk.bringToTop(); + } + +} + +function render() { + game.debug.renderInputInfo(32, 32); +} diff --git a/src/core/Group.js b/src/core/Group.js index 0eb47cec..17a2b460 100644 --- a/src/core/Group.js +++ b/src/core/Group.js @@ -10,9 +10,9 @@ * @classdesc A Group is a container for display objects that allows for fast pooling, recycling and collision checks. * @constructor * @param {Phaser.Game} game - A reference to the currently running game. -* @param {*} parent - The parent Group, DisplayObject or DisplayObjectContainer that will hold this group. If undefined it will use game.world. +* @param {*} parent - The parent Group, DisplayObject or DisplayObjectContainer that this Group will be added to. If undefined or null it will use game.world. * @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging. -* @param {boolean} [useStage=false] - Should the DisplayObjectContainer this Group creates be added to the World (default, false) or direct to the Stage (true). +* @param {boolean} [useStage=false] - Should this Group be added to the World (default, false) or direct to the Stage (true). */ Phaser.Group = function (game, parent, name, useStage) { @@ -21,7 +21,7 @@ Phaser.Group = function (game, parent, name, useStage) { */ this.game = game; - if (typeof parent === 'undefined') + if (typeof parent === 'undefined' || parent === null) { parent = game.world; } @@ -34,34 +34,20 @@ Phaser.Group = function (game, parent, name, useStage) { PIXI.DisplayObjectContainer.call(this); if (typeof useStage === 'undefined') - { - useStage = false; - } - - if (useStage) - { - // this._container = this.game.stage._stage; - } - else { if (parent) { - // if (parent instanceof Phaser.Group) - // { - // parent.addChild(this); - // } - // else - // { - parent.addChild(this); - // parent.updateTransform(); - // } + parent.addChild(this); } else { this.game.stage._stage.addChild(this); - // this.game.stage._stage.updateTransform(); } } + else + { + this.game.stage._stage.addChild(this); + } /** * @property {number} type - Internal Phaser Type value. @@ -86,18 +72,14 @@ Phaser.Group = function (game, parent, name, useStage) { */ this.group = null; - // Replaces the PIXI.Point with a slightly more flexible one. - // this._container.scale = new Phaser.Point(1, 1); - /** - * @property {Phaser.Point} scale - The scane of the Group container. + * @property {Phaser.Point} scale - The scale of the Group container. */ - // this.scale = this._container.scale; + this.scale = new Phaser.Point(1, 1); /** * @property {Phaser.Point} pivot - The pivot point of the Group container. */ - // this.pivot = this._container.pivot; /** * The cursor is a simple way to iterate through the objects in a Group using the Group.next and Group.previous functions. @@ -164,8 +146,6 @@ Phaser.Group.prototype.add = function (child) { this.addChild(child); - // child.updateTransform(); - if (child.events) { child.events.onAddedToGroup.dispatch(child, this); @@ -198,8 +178,6 @@ Phaser.Group.prototype.addAt = function (child, index) { this.addChildAt(child, index); - // child.updateTransform(); - if (child.events) { child.events.onAddedToGroup.dispatch(child, this); @@ -253,8 +231,6 @@ Phaser.Group.prototype.create = function (x, y, key, frame, exists) { this.addChild(child); - // child.updateTransform(); - if (child.events) { child.events.onAddedToGroup.dispatch(child, this); @@ -295,8 +271,6 @@ Phaser.Group.prototype.createMultiple = function (quantity, key, frame, exists) this.addChild(child); - // child.updateTransform(); - if (child.events) { child.events.onAddedToGroup.dispatch(child, this); @@ -433,7 +407,6 @@ Phaser.Group.prototype.replace = function (oldChild, newChild) { this.addChildAt(newChild, index); newChild.events.onAddedToGroup.dispatch(newChild, this); - // newChild.updateTransform(); if (this.cursor === oldChild) { @@ -860,41 +833,10 @@ Phaser.Group.prototype.sort = function (index, order) { if (typeof index === 'undefined') { index = 'y'; } if (typeof order === 'undefined') { order = Phaser.Group.SORT_ASCENDING; } - /* - var swapped; - var temp; - do { +} - swapped = false; - - for (var i = 0, len = this._container.children.length - 1; i < len; i++) - { - if (order == Phaser.Group.SORT_ASCENDING) - { - if (this._container.children[i][index] > this._container.children[i + 1][index]) - { - this.swap(this.getAt(i), this.getAt(i + 1)); - temp = this._container.children[i]; - this._container.children[i] = this._container.children[i + 1]; - this._container.children[i + 1] = temp; - swapped = true; - } - } - else - { - if (this._container.children[i][index] < this._container.children[i + 1][index]) - { - this.swap(this.getAt(i), this.getAt(i + 1)); - temp = this._container.children[i]; - this._container.children[i] = this._container.children[i + 1]; - this._container.children[i + 1] = temp; - swapped = true; - } - } - } - } while (swapped); - */ +Phaser.Group.prototype.sortHandler = function (a, b) { } diff --git a/src/utils/Utils.js b/src/utils/Utils.js index ac501e69..f1c489d7 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -197,12 +197,64 @@ Phaser.Utils = { }; -function HEXtoRGB(hex) { +/** + * Converts a hex color number to an [R, G, B] array + * + * @method hex2rgb + * @param hex {Number} + */ +PIXI.hex2rgb = function(hex) { return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255]; -} +}; -PIXI.hex2rgb = function hex2rgb(hex) { - return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255]; +/** + * Converts a color as an [R, G, B] array to a hex number + * + * @method rgb2hex + * @param rgb {Array} + */ +PIXI.rgb2hex = function(rgb) { + return ((rgb[0]*255 << 16) + (rgb[1]*255 << 8) + rgb[2]*255); +}; + +/** + * Checks whether the Canvas BlendModes are supported by the current browser + * + * @method canUseNewCanvasBlendModes + * @return {Boolean} whether they are supported + */ +PIXI.canUseNewCanvasBlendModes = function() +{ + var canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + var context = canvas.getContext('2d'); + context.fillStyle = '#000'; + context.fillRect(0,0,1,1); + context.globalCompositeOperation = 'multiply'; + context.fillStyle = '#fff'; + context.fillRect(0,0,1,1); + return context.getImageData(0,0,1,1).data[0] === 0; +}; + +/** + * Given a number, this function returns the closest number that is a power of two + * this function is taken from Starling Framework as its pretty neat ;) + * + * @method getNextPowerOfTwo + * @param number {Number} + * @return {Number} the closest number that is a power of two + */ +PIXI.getNextPowerOfTwo = function(number) +{ + if (number > 0 && (number & (number - 1)) === 0) // see: http://goo.gl/D9kPj + return number; + else + { + var result = 1; + while (result < number) result <<= 1; + return result; + } }; /**