mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
Tidying up source code for release. Also refactored World to use a Group instance, rather tha duplicate functions.
This commit is contained in:
parent
87858d6bbf
commit
f260108433
25 changed files with 278 additions and 487 deletions
|
@ -31,6 +31,10 @@
|
|||
|
||||
game.stage.backgroundColor = '#e3ed49';
|
||||
|
||||
// Testing iOS7 lack of fullscreen. Damnit.
|
||||
document.documentElement['style'].minHeight = '2000px';
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
|
||||
game.input.onDown.add(gofull, this);
|
||||
|
||||
}
|
||||
|
@ -40,6 +44,13 @@
|
|||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (document.getElementsByTagName('body')[0].scrollTop > 1000)
|
||||
{
|
||||
game.stage.backgroundColor = '#87ff55';
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
var x = (i * 64);
|
||||
s = g.create(x, 0, 'diamond');
|
||||
var x = 50 + (i * 64);
|
||||
s = g.create(x, 100, 'diamond');
|
||||
s.name = 'd' + i;
|
||||
s.anchor.setTo(0.5, 0.5);
|
||||
}
|
||||
|
@ -68,8 +68,8 @@
|
|||
|
||||
function update() {
|
||||
|
||||
// g.addAll('angle', 10);
|
||||
g.angle++;
|
||||
g.addAll('angle', 10);
|
||||
// g.angle++;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#182d3b';
|
||||
game.input.touch.preventDefault = false;
|
||||
|
||||
music = game.add.audio('boden');
|
||||
music.play();
|
||||
|
|
|
@ -168,10 +168,7 @@ Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
|
|||
|
||||
get: function () {
|
||||
return this._frames.length;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@ -200,9 +197,6 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", {
|
|||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -217,10 +217,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
|
|||
|
||||
get: function () {
|
||||
return this._frameData;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
|
||||
|
@ -235,10 +233,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
|
||||
|
@ -266,10 +262,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
|
|||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
|
||||
|
@ -296,8 +290,6 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
|
|||
{
|
||||
console.warn("Cannot set frameName: " + value);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
|
|
@ -92,6 +92,7 @@ Phaser.Animation.FrameData.prototype = {
|
|||
}
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -105,7 +106,8 @@ Phaser.Animation.FrameData.prototype = {
|
|||
|
||||
if (typeof output === "undefined") { output = []; }
|
||||
|
||||
for (var i = start; i <= end; i++) {
|
||||
for (var i = start; i <= end; i++)
|
||||
{
|
||||
output.push(this._frames[i]);
|
||||
}
|
||||
|
||||
|
@ -122,7 +124,8 @@ Phaser.Animation.FrameData.prototype = {
|
|||
|
||||
if (typeof output === "undefined") { output = []; }
|
||||
|
||||
for (var i = 0; i < this._frames.length; i++) {
|
||||
for (var i = 0; i < this._frames.length; i++)
|
||||
{
|
||||
output.push(i);
|
||||
}
|
||||
|
||||
|
@ -139,12 +142,12 @@ Phaser.Animation.FrameData.prototype = {
|
|||
|
||||
var output = [];
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
|
||||
if (this.getFrameByName(input[i])) {
|
||||
for (var i = 0; i < input.length; i++)
|
||||
{
|
||||
if (this.getFrameByName(input[i]))
|
||||
{
|
||||
output.push(this.getFrameByName(input[i]).index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -168,7 +171,8 @@ Phaser.Animation.FrameData.prototype = {
|
|||
|
||||
var output = [];
|
||||
|
||||
for (var i = 0; i < range.length; i++) {
|
||||
for (var i = 0; i < range.length; i++)
|
||||
{
|
||||
output.push(this._frames[i]);
|
||||
}
|
||||
|
||||
|
@ -178,10 +182,10 @@ Phaser.Animation.FrameData.prototype = {
|
|||
};
|
||||
|
||||
Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", {
|
||||
|
||||
get: function () {
|
||||
return this._frames.length;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -207,10 +207,8 @@ Object.defineProperty(Phaser.Camera.prototype, "x", {
|
|||
|
||||
set: function (value) {
|
||||
this.view.x = value;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Camera.prototype, "y", {
|
||||
|
@ -221,10 +219,8 @@ Object.defineProperty(Phaser.Camera.prototype, "y", {
|
|||
|
||||
set: function (value) {
|
||||
this.view.y = value;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Camera.prototype, "width", {
|
||||
|
@ -235,10 +231,8 @@ Object.defineProperty(Phaser.Camera.prototype, "width", {
|
|||
|
||||
set: function (value) {
|
||||
this.view.width = value;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Camera.prototype, "height", {
|
||||
|
@ -249,8 +243,6 @@ Object.defineProperty(Phaser.Camera.prototype, "height", {
|
|||
|
||||
set: function (value) {
|
||||
this.view.height = value;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
|
|
@ -447,9 +447,7 @@ Object.defineProperty(Phaser.Game.prototype, "paused", {
|
|||
}
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
|
|
@ -1,27 +1,39 @@
|
|||
Phaser.Group = function (game, parent, name) {
|
||||
Phaser.Group = function (game, parent, name, useStage) {
|
||||
|
||||
parent = parent || null;
|
||||
|
||||
if (typeof useStage == 'undefined')
|
||||
{
|
||||
useStage = false;
|
||||
}
|
||||
|
||||
this.game = game;
|
||||
this.name = name || 'group';
|
||||
|
||||
this._container = new PIXI.DisplayObjectContainer();
|
||||
this._container.name = this.name;
|
||||
|
||||
if (parent)
|
||||
if (useStage)
|
||||
{
|
||||
if (parent instanceof Phaser.Group)
|
||||
{
|
||||
parent._container.addChild(this._container);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent.addChild(this._container);
|
||||
}
|
||||
this._container = this.game.stage._stage;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.world.add(this._container);
|
||||
this._container = new PIXI.DisplayObjectContainer();
|
||||
this._container.name = this.name;
|
||||
|
||||
if (parent)
|
||||
{
|
||||
if (parent instanceof Phaser.Group)
|
||||
{
|
||||
parent._container.addChild(this._container);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent.addChild(this._container);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.stage._stage.addChild(this._container);
|
||||
}
|
||||
}
|
||||
|
||||
this.exists = true;
|
||||
|
@ -274,13 +286,13 @@ Phaser.Group.prototype = {
|
|||
sortHandler: function (obj1, obj2) {
|
||||
|
||||
/*
|
||||
if(!obj1 || !obj2) {
|
||||
if (!obj1 || !obj2) {
|
||||
//console.log('null objects in sort', obj1, obj2);
|
||||
return 0;
|
||||
}
|
||||
if(obj1[this._sortIndex] < obj2[this._sortIndex]) {
|
||||
if (obj1[this._sortIndex] < obj2[this._sortIndex]) {
|
||||
return this._sortOrder;
|
||||
} else if(obj1[this._sortIndex] > obj2[this._sortIndex]) {
|
||||
} else if (obj1[this._sortIndex] > obj2[this._sortIndex]) {
|
||||
return -this._sortOrder;
|
||||
}
|
||||
return 0;
|
||||
|
@ -788,10 +800,8 @@ Object.defineProperty(Phaser.Group.prototype, "x", {
|
|||
|
||||
set: function (value) {
|
||||
this._container.position.x = value;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Group.prototype, "y", {
|
||||
|
@ -802,10 +812,8 @@ Object.defineProperty(Phaser.Group.prototype, "y", {
|
|||
|
||||
set: function (value) {
|
||||
this._container.position.y = value;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Group.prototype, "angle", {
|
||||
|
@ -816,10 +824,8 @@ Object.defineProperty(Phaser.Group.prototype, "angle", {
|
|||
|
||||
set: function(value) {
|
||||
this._container.rotation = Phaser.Math.degToRad(value);
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Group.prototype, "rotation", {
|
||||
|
@ -830,10 +836,8 @@ Object.defineProperty(Phaser.Group.prototype, "rotation", {
|
|||
|
||||
set: function (value) {
|
||||
this._container.rotation = value;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Group.prototype, "visible", {
|
||||
|
@ -844,8 +848,6 @@ Object.defineProperty(Phaser.Group.prototype, "visible", {
|
|||
|
||||
set: function (value) {
|
||||
this._container.visible = value;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
|
|
@ -91,55 +91,13 @@ Phaser.LinkedList.prototype = {
|
|||
|
||||
dump: function () {
|
||||
|
||||
console.log("\nNode\t\t|\t\tNext\t\t|\t\tPrev\t\t|\t\tFirst\t\t|\t\tLast");
|
||||
console.log("\t\t\t|\t\t\t\t\t|\t\t\t\t\t|\t\t\t\t\t|");
|
||||
var spacing = 20;
|
||||
|
||||
var nameNext = '-';
|
||||
var namePrev = '-';
|
||||
var nameFirst = '-';
|
||||
var nameLast = '-';
|
||||
var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing);
|
||||
console.log(output);
|
||||
|
||||
if (this.next)
|
||||
{
|
||||
nameNext = this.next.sprite.name;
|
||||
}
|
||||
|
||||
if (this.prev)
|
||||
{
|
||||
namePrev = this.prev.sprite.name;
|
||||
}
|
||||
|
||||
if (this.first)
|
||||
{
|
||||
nameFirst = this.first.sprite.name;
|
||||
}
|
||||
|
||||
if (this.last)
|
||||
{
|
||||
nameLast = this.last.sprite.name;
|
||||
}
|
||||
|
||||
if (typeof nameNext === 'undefined')
|
||||
{
|
||||
nameNext = '-';
|
||||
}
|
||||
|
||||
if (typeof namePrev === 'undefined')
|
||||
{
|
||||
namePrev = '-';
|
||||
}
|
||||
|
||||
if (typeof nameFirst === 'undefined')
|
||||
{
|
||||
nameFirst = '-';
|
||||
}
|
||||
|
||||
if (typeof nameLast === 'undefined')
|
||||
{
|
||||
nameLast = '-';
|
||||
}
|
||||
|
||||
console.log('HD' + '\t\t\t|\t\t' + nameNext + '\t\t\t|\t\t' + namePrev + '\t\t\t|\t\t' + nameFirst + '\t\t\t|\t\t' + nameLast);
|
||||
var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing);
|
||||
console.log(output);
|
||||
|
||||
var entity = this;
|
||||
|
||||
|
@ -194,7 +152,8 @@ Phaser.LinkedList.prototype = {
|
|||
nameLast = '-';
|
||||
}
|
||||
|
||||
console.log(name + '\t\t\t|\t\t' + nameNext + '\t\t\t|\t\t' + namePrev + '\t\t\t|\t\t' + nameFirst + '\t\t\t|\t\t' + nameLast);
|
||||
var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing);
|
||||
console.log(output);
|
||||
|
||||
entity = entity.next;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ Phaser.Signal.prototype = {
|
|||
this._addBinding(binding);
|
||||
}
|
||||
|
||||
if(this.memorize && this._prevParams){
|
||||
if (this.memorize && this._prevParams){
|
||||
binding.execute(this._prevParams);
|
||||
}
|
||||
|
||||
|
|
|
@ -101,8 +101,6 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", {
|
|||
|
||||
this._stage.setBackgroundColor(color);
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
|
|
@ -1,52 +1,65 @@
|
|||
/**
|
||||
* World
|
||||
*
|
||||
* "This world is but a canvas to our imagination." - Henry David Thoreau
|
||||
*
|
||||
* A game has only one world. The world is an abstract place in which all game objects live. It is not bound
|
||||
* by stage limits and can be any size. You look into the world via cameras. All game objects live within
|
||||
* the world at world-based coordinates. By default a world is created the same size as your Stage.
|
||||
*
|
||||
* @package Phaser.World
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
*/
|
||||
Phaser.World = function (game) {
|
||||
|
||||
/**
|
||||
* Local reference to Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* Bound of this world that objects can not escape from.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height);
|
||||
|
||||
/**
|
||||
* Camera instance.
|
||||
* @type {Camera}
|
||||
*/
|
||||
this.camera = null;
|
||||
|
||||
/**
|
||||
* Reset each frame, keeps a count of the total number of objects updated.
|
||||
* @type {Number}
|
||||
*/
|
||||
this.currentRenderOrderID = 0;
|
||||
|
||||
/**
|
||||
* Object container stores every object created with `create*` methods.
|
||||
* @type {Group}
|
||||
*/
|
||||
this.group = null;
|
||||
|
||||
};
|
||||
|
||||
Phaser.World.prototype = {
|
||||
|
||||
|
||||
boot: function () {
|
||||
|
||||
this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height);
|
||||
|
||||
this.game.camera = this.camera;
|
||||
|
||||
},
|
||||
|
||||
add: function (gameobject) {
|
||||
|
||||
this.game.stage._stage.addChild(gameobject);
|
||||
return gameobject;
|
||||
|
||||
},
|
||||
|
||||
addAt: function (gameobject, index) {
|
||||
|
||||
this.game.stage._stage.addChildAt(gameobject, index);
|
||||
return gameobject;
|
||||
|
||||
},
|
||||
|
||||
getAt: function (index) {
|
||||
|
||||
return this.game.stage._stage.getChildAt(index);
|
||||
|
||||
},
|
||||
|
||||
remove: function (gameobject) {
|
||||
|
||||
this.game.stage._stage.removeChild(gameobject);
|
||||
return gameobject;
|
||||
this.group = new Phaser.Group(this.game, null, '__world', true);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* This is called automatically every frame, and is where main logic happens.
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
this.camera.update();
|
||||
|
@ -87,137 +100,8 @@ Phaser.World.prototype = {
|
|||
this.bounds.width = width;
|
||||
this.bounds.height = height;
|
||||
|
||||
},
|
||||
|
||||
bringToTop: function (child) {
|
||||
|
||||
this.remove(child);
|
||||
this.add(child);
|
||||
|
||||
return child;
|
||||
|
||||
},
|
||||
|
||||
swapChildren: function (child1, child2) {
|
||||
|
||||
if (child1 === child2 || !child1.parent || !child2.parent)
|
||||
{
|
||||
console.warn('You cannot swap a child with itself or swap un-parented children');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Cache the values
|
||||
var child1Prev = child1._iPrev;
|
||||
var child1Next = child1._iNext;
|
||||
var child2Prev = child2._iPrev;
|
||||
var child2Next = child2._iNext;
|
||||
|
||||
var endNode = this.game.stage._stage.last._iNext;
|
||||
var currentNode = this.game.stage._stage.first;
|
||||
|
||||
do
|
||||
{
|
||||
if (currentNode !== child1 && currentNode !== child2)
|
||||
{
|
||||
if (currentNode.first === child1)
|
||||
{
|
||||
currentNode.first = child2;
|
||||
}
|
||||
else if (currentNode.first === child2)
|
||||
{
|
||||
currentNode.first = child1;
|
||||
}
|
||||
|
||||
if (currentNode.last === child1)
|
||||
{
|
||||
currentNode.last = child2;
|
||||
}
|
||||
else if (currentNode.last === child2)
|
||||
{
|
||||
currentNode.last = child1;
|
||||
}
|
||||
}
|
||||
|
||||
currentNode = currentNode._iNext;
|
||||
}
|
||||
while (currentNode != endNode)
|
||||
|
||||
if (child1._iNext == child2)
|
||||
{
|
||||
// This is a downward (A to B) neighbour swap
|
||||
child1._iNext = child2Next;
|
||||
child1._iPrev = child2;
|
||||
child2._iNext = child1;
|
||||
child2._iPrev = child1Prev;
|
||||
|
||||
if (child1Prev) { child1Prev._iNext = child2; }
|
||||
if (child2Next) { child2Next._iPrev = child1; }
|
||||
|
||||
if (child1.__renderGroup)
|
||||
{
|
||||
child1.__renderGroup.updateTexture(child1);
|
||||
}
|
||||
|
||||
if (child2.__renderGroup)
|
||||
{
|
||||
child2.__renderGroup.updateTexture(child2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (child2._iNext == child1)
|
||||
{
|
||||
// This is an upward (B to A) neighbour swap
|
||||
child1._iNext = child2;
|
||||
child1._iPrev = child2Prev;
|
||||
child2._iNext = child1Next;
|
||||
child2._iPrev = child1;
|
||||
|
||||
if (child2Prev) { child2Prev._iNext = child1; }
|
||||
if (child1Next) { child2Next._iPrev = child2; }
|
||||
|
||||
if (child1.__renderGroup)
|
||||
{
|
||||
child1.__renderGroup.updateTexture(child1);
|
||||
}
|
||||
|
||||
if (child2.__renderGroup)
|
||||
{
|
||||
child2.__renderGroup.updateTexture(child2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Children are far apart
|
||||
child1._iNext = child2Next;
|
||||
child1._iPrev = child2Prev;
|
||||
child2._iNext = child1Next;
|
||||
child2._iPrev = child1Prev;
|
||||
|
||||
if (child1Prev) { child1Prev._iNext = child2; }
|
||||
if (child1Next) { child1Next._iPrev = child2; }
|
||||
if (child2Prev) { child2Prev._iNext = child1; }
|
||||
if (child2Next) { child2Next._iPrev = child1; }
|
||||
|
||||
if (child1.__renderGroup)
|
||||
{
|
||||
child1.__renderGroup.updateTexture(child1);
|
||||
}
|
||||
|
||||
if (child2.__renderGroup)
|
||||
{
|
||||
child2.__renderGroup.updateTexture(child2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
// Getters / Setters
|
||||
|
@ -230,10 +114,8 @@ Object.defineProperty(Phaser.World.prototype, "width", {
|
|||
|
||||
set: function (value) {
|
||||
this.bounds.width = value;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.World.prototype, "height", {
|
||||
|
@ -244,48 +126,38 @@ Object.defineProperty(Phaser.World.prototype, "height", {
|
|||
|
||||
set: function (value) {
|
||||
this.bounds.height = value;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.World.prototype, "centerX", {
|
||||
|
||||
get: function () {
|
||||
return this.bounds.halfWidth;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.World.prototype, "centerY", {
|
||||
|
||||
get: function () {
|
||||
return this.bounds.halfHeight;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.World.prototype, "randomX", {
|
||||
|
||||
get: function () {
|
||||
return Math.round(Math.random() * this.bounds.width);
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.World.prototype, "randomY", {
|
||||
|
||||
get: function () {
|
||||
return Math.round(Math.random() * this.bounds.height);
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ Phaser.GameObjectFactory.prototype = {
|
|||
|
||||
existing: function (object) {
|
||||
|
||||
return this.world.add(object);
|
||||
return this.world.group.add(object);
|
||||
|
||||
},
|
||||
|
||||
|
@ -27,7 +27,7 @@ Phaser.GameObjectFactory.prototype = {
|
|||
*/
|
||||
sprite: function (x, y, key, frame) {
|
||||
|
||||
return this.world.add(new Phaser.Sprite(this.game, x, y, key, frame));
|
||||
return this.world.group.add(new Phaser.Sprite(this.game, x, y, key, frame));
|
||||
|
||||
},
|
||||
|
||||
|
@ -42,7 +42,7 @@ Phaser.GameObjectFactory.prototype = {
|
|||
*/
|
||||
child: function (parent, x, y, key, frame) {
|
||||
|
||||
var child = this.world.add(new Phaser.Sprite(this.game, x, y, key, frame));
|
||||
var child = this.world.group.add(new Phaser.Sprite(this.game, x, y, key, frame));
|
||||
parent.addChild(child);
|
||||
return child;
|
||||
|
||||
|
@ -74,25 +74,25 @@ Phaser.GameObjectFactory.prototype = {
|
|||
|
||||
tileSprite: function (x, y, width, height, key, frame) {
|
||||
|
||||
return this.world.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame));
|
||||
return this.world.group.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame));
|
||||
|
||||
},
|
||||
|
||||
text: function (x, y, text, style) {
|
||||
|
||||
return this.world.add(new Phaser.Text(this.game, x, y, text, style));
|
||||
return this.world.group.add(new Phaser.Text(this.game, x, y, text, style));
|
||||
|
||||
},
|
||||
|
||||
button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) {
|
||||
|
||||
return this.world.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame));
|
||||
return this.world.group.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame));
|
||||
|
||||
},
|
||||
|
||||
graphics: function (x, y) {
|
||||
|
||||
return this.world.add(new Phaser.Graphics(this.game, x, y));
|
||||
return this.world.group.add(new Phaser.Graphics(this.game, x, y));
|
||||
|
||||
},
|
||||
|
||||
|
@ -104,7 +104,7 @@ Phaser.GameObjectFactory.prototype = {
|
|||
|
||||
bitmapText: function (x, y, text, style) {
|
||||
|
||||
return this.world.add(new Phaser.BitmapText(this.game, x, y, text, style));
|
||||
return this.world.group.add(new Phaser.BitmapText(this.game, x, y, text, style));
|
||||
|
||||
},
|
||||
|
||||
|
|
|
@ -205,13 +205,12 @@ Object.defineProperty(Phaser.Circle.prototype, "diameter", {
|
|||
* @param {Number} The diameter of the circle.
|
||||
**/
|
||||
set: function (value) {
|
||||
if(value > 0) {
|
||||
if (value > 0) {
|
||||
this._diameter = value;
|
||||
this._radius = value * 0.5;
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Circle.prototype, "radius", {
|
||||
|
@ -231,13 +230,12 @@ Object.defineProperty(Phaser.Circle.prototype, "radius", {
|
|||
* @param {Number} The radius of the circle.
|
||||
**/
|
||||
set: function (value) {
|
||||
if(value > 0) {
|
||||
if (value > 0) {
|
||||
this._radius = value;
|
||||
this._diameter = value * 2;
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Circle.prototype, "left", {
|
||||
|
@ -257,15 +255,14 @@ Object.defineProperty(Phaser.Circle.prototype, "left", {
|
|||
* @param {Number} The value to adjust the position of the leftmost point of the circle by.
|
||||
**/
|
||||
set: function (value) {
|
||||
if(value > this.x) {
|
||||
if (value > this.x) {
|
||||
this._radius = 0;
|
||||
this._diameter = 0;
|
||||
} else {
|
||||
this.radius = this.x - value;
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Circle.prototype, "right", {
|
||||
|
@ -285,15 +282,14 @@ Object.defineProperty(Phaser.Circle.prototype, "right", {
|
|||
* @param {Number} The amount to adjust the diameter of the circle by.
|
||||
**/
|
||||
set: function (value) {
|
||||
if(value < this.x) {
|
||||
if (value < this.x) {
|
||||
this._radius = 0;
|
||||
this._diameter = 0;
|
||||
} else {
|
||||
this.radius = value - this.x;
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Circle.prototype, "top", {
|
||||
|
@ -313,15 +309,14 @@ Object.defineProperty(Phaser.Circle.prototype, "top", {
|
|||
* @param {Number} The amount to adjust the height of the circle by.
|
||||
**/
|
||||
set: function (value) {
|
||||
if(value > this.y) {
|
||||
if (value > this.y) {
|
||||
this._radius = 0;
|
||||
this._diameter = 0;
|
||||
} else {
|
||||
this.radius = this.y - value;
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Circle.prototype, "bottom", {
|
||||
|
@ -348,9 +343,8 @@ Object.defineProperty(Phaser.Circle.prototype, "bottom", {
|
|||
} else {
|
||||
this.radius = value - this.y;
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Circle.prototype, "area", {
|
||||
|
@ -361,14 +355,13 @@ Object.defineProperty(Phaser.Circle.prototype, "area", {
|
|||
* @return {Number} This area of this circle.
|
||||
**/
|
||||
get: function () {
|
||||
if(this._radius > 0) {
|
||||
if (this._radius > 0) {
|
||||
return Math.PI * this._radius * this._radius;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Circle.prototype, "empty", {
|
||||
|
@ -389,9 +382,8 @@ Object.defineProperty(Phaser.Circle.prototype, "empty", {
|
|||
**/
|
||||
set: function (value) {
|
||||
this.setTo(0, 0, 0);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Statics
|
||||
|
|
|
@ -266,9 +266,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "halfWidth", {
|
|||
**/
|
||||
get: function () {
|
||||
return Math.round(this.width / 2);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", {
|
||||
|
@ -280,9 +279,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", {
|
|||
**/
|
||||
get: function () {
|
||||
return Math.round(this.height / 2);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "bottom", {
|
||||
|
@ -302,14 +300,13 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottom", {
|
|||
* @param {Number} value
|
||||
**/
|
||||
set: function (value) {
|
||||
if(value <= this.y) {
|
||||
if (value <= this.y) {
|
||||
this.height = 0;
|
||||
} else {
|
||||
this.height = (this.y - value);
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", {
|
||||
|
@ -330,9 +327,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", {
|
|||
set: function (value) {
|
||||
this.right = value.x;
|
||||
this.bottom = value.y;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "left", {
|
||||
|
@ -359,9 +355,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "left", {
|
|||
this.width = this.right - value;
|
||||
}
|
||||
this.x = value;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "right", {
|
||||
|
@ -383,14 +378,13 @@ Object.defineProperty(Phaser.Rectangle.prototype, "right", {
|
|||
* @param {Number} value
|
||||
**/
|
||||
set: function (value) {
|
||||
if(value <= this.x) {
|
||||
if (value <= this.x) {
|
||||
this.width = 0;
|
||||
} else {
|
||||
this.width = this.x + value;
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "volume", {
|
||||
|
@ -402,9 +396,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "volume", {
|
|||
**/
|
||||
get: function () {
|
||||
return this.width * this.height;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
|
||||
|
@ -416,9 +409,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
|
|||
**/
|
||||
get: function () {
|
||||
return (this.width * 2) + (this.height * 2);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "centerX", {
|
||||
|
@ -439,9 +431,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerX", {
|
|||
**/
|
||||
set: function (value) {
|
||||
this.x = value - this.halfWidth;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "centerY", {
|
||||
|
@ -462,9 +453,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerY", {
|
|||
**/
|
||||
set: function (value) {
|
||||
this.y = value - this.halfHeight;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "top", {
|
||||
|
@ -486,15 +476,14 @@ Object.defineProperty(Phaser.Rectangle.prototype, "top", {
|
|||
* @param {Number} value
|
||||
**/
|
||||
set: function (value) {
|
||||
if(value >= this.bottom) {
|
||||
if (value >= this.bottom) {
|
||||
this.height = 0;
|
||||
this.y = value;
|
||||
} else {
|
||||
this.height = (this.bottom - value);
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", {
|
||||
|
@ -515,9 +504,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", {
|
|||
set: function (value) {
|
||||
this.x = value.x;
|
||||
this.y = value.y;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
|
||||
|
@ -538,9 +526,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
|
|||
**/
|
||||
set: function (value) {
|
||||
this.setTo(0, 0, 0, 0);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Statics
|
||||
|
|
|
@ -456,7 +456,7 @@ Phaser.Input.prototype = {
|
|||
{
|
||||
return this.pointer1.move(event);
|
||||
}
|
||||
else if(this.pointer2.active && this.pointer2.identifier == event.identifier)
|
||||
else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer2.move(event);
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ Phaser.Input.prototype = {
|
|||
{
|
||||
return this.pointer1.stop(event);
|
||||
}
|
||||
else if(this.pointer2.active && this.pointer2.identifier == event.identifier)
|
||||
else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer2.stop(event);
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ Phaser.Input.prototype = {
|
|||
{
|
||||
return this.pointer1;
|
||||
}
|
||||
else if(this.pointer2.active == state)
|
||||
else if (this.pointer2.active == state)
|
||||
{
|
||||
return this.pointer2;
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ Phaser.Input.prototype = {
|
|||
{
|
||||
return this.pointer1;
|
||||
}
|
||||
else if(this.pointer2.identifier == identifier)
|
||||
else if (this.pointer2.identifier == identifier)
|
||||
{
|
||||
return this.pointer2;
|
||||
}
|
||||
|
@ -608,10 +608,8 @@ Object.defineProperty(Phaser.Input.prototype, "x", {
|
|||
|
||||
set: function (value) {
|
||||
this._x = Math.floor(value);
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "y", {
|
||||
|
@ -628,20 +626,16 @@ Object.defineProperty(Phaser.Input.prototype, "y", {
|
|||
|
||||
set: function (value) {
|
||||
this._y = Math.floor(value);
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "pollLocked", {
|
||||
|
||||
get: function () {
|
||||
return (this.pollRate > 0 && this._pollCounter < this.pollRate);
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", {
|
||||
|
@ -653,10 +647,8 @@ Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", {
|
|||
**/
|
||||
get: function () {
|
||||
return 10 - this.currentPointers;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", {
|
||||
|
@ -680,28 +672,22 @@ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", {
|
|||
|
||||
return this.currentPointers;
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "worldX", {
|
||||
|
||||
get: function () {
|
||||
return this.game.camera.view.x + this.x;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "worldY", {
|
||||
|
||||
get: function () {
|
||||
return this.game.camera.view.y + this.y;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
|
|
@ -611,10 +611,8 @@ Object.defineProperty(Phaser.Pointer.prototype, "duration", {
|
|||
|
||||
return this.game.time.now - this.timeDown;
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
|
||||
|
@ -627,10 +625,8 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
|
|||
|
||||
return this.game.world.camera.x + this.x;
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
|
||||
|
@ -643,8 +639,6 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
|
|||
|
||||
return this.game.world.camera.y + this.y;
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
|
|
@ -19,6 +19,8 @@ Phaser.Touch = function (game) {
|
|||
this.touchLeaveCallback = null;
|
||||
this.touchCancelCallback = null;
|
||||
|
||||
this.preventDefault = true;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Touch.prototype = {
|
||||
|
@ -73,30 +75,28 @@ Phaser.Touch.prototype = {
|
|||
return _this.onTouchCancel(event);
|
||||
};
|
||||
|
||||
this._documentTouchMove = function (event) {
|
||||
return _this.consumeTouchMove(event);
|
||||
};
|
||||
|
||||
this.game.renderer.view.addEventListener('touchstart', this._onTouchStart, false);
|
||||
this.game.renderer.view.addEventListener('touchmove', this._onTouchMove, false);
|
||||
this.game.renderer.view.addEventListener('touchend', this._onTouchEnd, false);
|
||||
this.game.renderer.view.addEventListener('touchenter', this._onTouchEnter, false);
|
||||
this.game.renderer.view.addEventListener('touchleave', this._onTouchLeave, false);
|
||||
this.game.renderer.view.addEventListener('touchcancel', this._onTouchCancel, false);
|
||||
|
||||
document.addEventListener('touchmove', this._documentTouchMove, false);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Prevent iOS bounce-back (doesn't work?)
|
||||
/**
|
||||
* Consumes all touchmove events on the document (only enable this if you know you need it!)
|
||||
* @method consumeTouchMove
|
||||
* @param {Any} event
|
||||
**/
|
||||
consumeTouchMove: function (event) {
|
||||
consumeDocumentTouches: function () {
|
||||
|
||||
event.preventDefault();
|
||||
this._documentTouchMove = function (event) {
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
document.addEventListener('touchmove', this._documentTouchMove, false);
|
||||
|
||||
},
|
||||
|
||||
|
@ -117,7 +117,10 @@ Phaser.Touch.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element)
|
||||
// event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element
|
||||
|
@ -147,7 +150,10 @@ Phaser.Touch.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome)
|
||||
// http://www.w3.org/TR/touch-events/#dfn-touchcancel
|
||||
|
@ -176,7 +182,10 @@ Phaser.Touch.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
|
@ -198,7 +207,10 @@ Phaser.Touch.prototype = {
|
|||
this.touchLeaveCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
|
@ -219,7 +231,10 @@ Phaser.Touch.prototype = {
|
|||
this.touchMoveCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
|
@ -240,7 +255,10 @@ Phaser.Touch.prototype = {
|
|||
this.touchEndCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// For touch end its a list of the touch points that have been removed from the surface
|
||||
// https://developer.mozilla.org/en-US/docs/DOM/TouchList
|
||||
|
@ -266,8 +284,6 @@ Phaser.Touch.prototype = {
|
|||
this.game.stage.canvas.removeEventListener('touchenter', this._onTouchEnter);
|
||||
this.game.stage.canvas.removeEventListener('touchleave', this._onTouchLeave);
|
||||
this.game.stage.canvas.removeEventListener('touchcancel', this._onTouchCancel);
|
||||
|
||||
document.removeEventListener('touchmove', this._documentTouchMove);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -509,9 +509,9 @@ Phaser.Math = {
|
|||
*/
|
||||
angleLimit: function (angle, min, max) {
|
||||
var result = angle;
|
||||
if(angle > max) {
|
||||
if (angle > max) {
|
||||
result = max;
|
||||
} else if(angle < min) {
|
||||
} else if (angle < min) {
|
||||
result = min;
|
||||
}
|
||||
return result;
|
||||
|
@ -527,10 +527,10 @@ Phaser.Math = {
|
|||
var m = v.length - 1;
|
||||
var f = m * k;
|
||||
var i = Math.floor(f);
|
||||
if(k < 0) {
|
||||
if (k < 0) {
|
||||
return this.linear(v[0], v[1], f);
|
||||
}
|
||||
if(k > 1) {
|
||||
if (k > 1) {
|
||||
return this.linear(v[m], v[m - 1], m - f);
|
||||
}
|
||||
return this.linear(v[i], v[i + 1 > m ? m : i + 1], f - i);
|
||||
|
@ -545,7 +545,7 @@ Phaser.Math = {
|
|||
bezierInterpolation: function (v, k) {
|
||||
var b = 0;
|
||||
var n = v.length - 1;
|
||||
for(var i = 0; i <= n; i++) {
|
||||
for (var i = 0; i <= n; i++) {
|
||||
b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * this.bernstein(n, i);
|
||||
}
|
||||
return b;
|
||||
|
@ -564,15 +564,15 @@ Phaser.Math = {
|
|||
var i = Math.floor(f);
|
||||
|
||||
if (v[0] === v[m]) {
|
||||
if(k < 0) {
|
||||
if (k < 0) {
|
||||
i = Math.floor(f = m * (1 + k));
|
||||
}
|
||||
return this.catmullRom(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
|
||||
} else {
|
||||
if(k < 0) {
|
||||
if (k < 0) {
|
||||
return v[0] - (this.catmullRom(v[0], v[0], v[1], v[1], -f) - v[0]);
|
||||
}
|
||||
if(k > 1) {
|
||||
if (k > 1) {
|
||||
return v[m] - (this.catmullRom(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
|
||||
}
|
||||
return this.catmullRom(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
|
||||
|
|
|
@ -227,14 +227,18 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", {
|
|||
* @param {Number} value
|
||||
**/
|
||||
set: function (value) {
|
||||
if(value <= this.y) {
|
||||
|
||||
if (value <= this.y)
|
||||
{
|
||||
this.height = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this.height = (this.y - value);
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", {
|
||||
|
@ -256,12 +260,16 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", {
|
|||
* @param {Number} value
|
||||
**/
|
||||
set: function (value) {
|
||||
if(value <= this.x) {
|
||||
|
||||
if (value <= this.x)
|
||||
{
|
||||
this.width = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this.width = this.x + value;
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -420,7 +420,7 @@ Phaser.Sound.prototype = {
|
|||
this._sound.stop(0);
|
||||
}
|
||||
}
|
||||
else if(this.usingAudioTag)
|
||||
else if (this.usingAudioTag)
|
||||
{
|
||||
this._sound.pause();
|
||||
this._sound.currentTime = 0;
|
||||
|
@ -441,20 +441,16 @@ Object.defineProperty(Phaser.Sound.prototype, "isDecoding", {
|
|||
|
||||
get: function () {
|
||||
return this.game.cache.getSound(this.key).isDecoding;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Sound.prototype, "isDecoded", {
|
||||
|
||||
get: function () {
|
||||
return this.game.cache.isSoundDecoded(this.key);
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Sound.prototype, "mute", {
|
||||
|
@ -501,10 +497,8 @@ Object.defineProperty(Phaser.Sound.prototype, "mute", {
|
|||
|
||||
this.onMute.dispatch(this);
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Sound.prototype, "volume", {
|
||||
|
@ -529,8 +523,6 @@ Object.defineProperty(Phaser.Sound.prototype, "volume", {
|
|||
this._sound.volume = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
|
|
@ -72,11 +72,11 @@ Phaser.SoundManager.prototype = {
|
|||
{
|
||||
this.context = new window['AudioContext']();
|
||||
}
|
||||
else if(!!window['webkitAudioContext'])
|
||||
else if (!!window['webkitAudioContext'])
|
||||
{
|
||||
this.context = new window['webkitAudioContext']();
|
||||
}
|
||||
else if(!!window['Audio'])
|
||||
else if (!!window['Audio'])
|
||||
{
|
||||
this.usingWebAudio = false;
|
||||
this.usingAudioTag = true;
|
||||
|
@ -346,7 +346,6 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
|
|||
}
|
||||
}
|
||||
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -450,29 +450,23 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", {
|
|||
|
||||
return true;
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", {
|
||||
|
||||
get: function () {
|
||||
return this.orientation == 0 || this.orientation == 180;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", {
|
||||
|
||||
get: function () {
|
||||
return this.orientation === 90 || this.orientation === -90;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
|
|
@ -189,10 +189,10 @@ Phaser.Color = {
|
|||
if (typeof max === "undefined") { max = 255; }
|
||||
if (typeof alpha === "undefined") { alpha = 255; }
|
||||
// Sanity checks
|
||||
if(max > 255) {
|
||||
if (max > 255) {
|
||||
return Phaser.Color.getColor(255, 255, 255);
|
||||
}
|
||||
if(min > max) {
|
||||
if (min > max) {
|
||||
return Phaser.Color.getColor(255, 255, 255);
|
||||
}
|
||||
var red = min + Math.round(Math.random() * (max - min));
|
||||
|
|
Loading…
Reference in a new issue