From 8eae8feeccac50c076c66cab4cf7036270f48162 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Thu, 6 Feb 2014 03:34:27 +0000 Subject: [PATCH] More Group fixes to the new format. Updated list of included Pixi files to remove un-needed ones. --- build/config.php | 62 ++++++------ examples/_site/view_full.html | 94 ++++++++++++------- examples/_site/view_lite.html | 93 +++++++++++------- examples/assets/audio/protracker/shampoo.mod | Bin 0 -> 25658 bytes examples/audio/protracker.js | 3 +- examples/groups/bring a group to top.js | 4 +- examples/index.html | 4 +- examples/sideview.html | 2 +- examples/wip/pixi1.js | 2 + examples/wip/pixi2.js | 88 +++++++++++++++++ src/core/Group.js | 82 +++------------- src/utils/Utils.js | 60 +++++++++++- 12 files changed, 320 insertions(+), 174 deletions(-) create mode 100644 examples/assets/audio/protracker/shampoo.mod create mode 100644 examples/wip/pixi2.js 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 0000000000000000000000000000000000000000..08ecbd540538607cae61fd4a6fdde906380cf967 GIT binary patch literal 25658 zcmeHu4_I8)weOw-hhZi&!{N^W(_x&$5F`-jKu{C&#~_Akt0rpIXm5Qt(aJOT_D|Zz ztG%B-xQ~7>zT13FU%fB+e9tP{<~IMViH%l7Nr*;G%#@)tA>#lu6!HxLh8Y5x0fx+Z zYwvybIR{Llv3XPvdz+H0-fUVHDgXY#|xHhyRG_r8a;*TX*&f4F7i5B~GU ze}41_>id-EPz_MJMdA;?_uWnZC_eJ-P2Yd~QL$8RF-^H@d+ihV&j`2EY2T^OsqbA$ z773^r+6rp>IZp!m(iOR;D{^bDz|BA+a5LcdQkMu;ap;;$vEbboTy0?fHlsl;yv&%C z&Ho$amNp<=3YVIi#_Q7!M#BP=*<#KRO!x(TjbGAtS{(j@&v$PgAj4!~10`fVGpZ$P{`_EGO zl~^9zOYF~HRDM*`zQEQT9ywIit#c2^ab-@X3O#f zfAWg*=lh58rx)YT^^f2`M}96JpOKOl=M<0s1W5&Lm|(o3};#$Orhp9B11{C<)DO8maae|fxok^c~gzkdGz zVb1)3(4Sy!!WYZm^O-Wuq0@Laq{df~k5YZI{;Y3OlHRd@g8Bmd zSJ!|1dXE3!AowqDX6?U0`Jibe`bY7}Y7~_QV9z}K*Kt|jtWo*%{KxUnTCT8V`{npz|H=3aDh;&$lb3{lWFG%* zk-Wh85d8L2KotDs^&jI)$ZA7p%aeT*_bSzj{uQP~`F(0r00)nZE`UCS*5a=8% zUq~wu=d+#NXUx@XS`XBum%eyGQ5(%fT z<3L^{d|3anevrpCJy{>1e;vqwiQqqj^_$8-UOt1s_229wkca&Vwm%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V>T-Z%il4O6ap)fN# z6iLsq8>R+Fb!nFTG~;BXyGOFy49W8|Qkrq>?7*aylcgK%9@W|N(-QF*95m>-_}L*z z$eoM^#w>*n?(E>uBxi@O><^40a~fw!k4
- 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; + } }; /**