mirror of
https://github.com/wassname/phaser.git
synced 2026-06-30 16:40:20 +08:00
Fixed an error that stopped 2 tweens from being able to run on the same object. Also refactored a lot of the classes to remove prototype properties and move them to local instance properties.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, render: render });
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>phaser.js - a new beginning</title>
|
||||
<?php
|
||||
require('js.php');
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
var tempSprite = game.add.sprite(0, 0, 'atari1');
|
||||
|
||||
game.add.tween(tempSprite).to({ x: 600 }, 4000, Phaser.Easing.Linear.None, true);
|
||||
game.add.tween(tempSprite).to({ y: 500 }, 4000, Phaser.Easing.Linear.None, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
function render() {
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -65,7 +65,7 @@ Phaser.Animation.prototype = {
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
// this._parent.events.onAnimationStart.dispatch(this._parent, this);
|
||||
this._parent.events.onAnimationStart.dispatch(this._parent, this);
|
||||
|
||||
return this;
|
||||
|
||||
@@ -114,7 +114,7 @@ Phaser.Animation.prototype = {
|
||||
this._frameIndex = 0;
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
// this._parent.events.onAnimationLoop.dispatch(this._parent, this);
|
||||
this._parent.events.onAnimationLoop.dispatch(this._parent, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -158,7 +158,7 @@ Phaser.Animation.prototype = {
|
||||
|
||||
this.isPlaying = false;
|
||||
this.isFinished = true;
|
||||
// this._parent.events.onAnimationComplete.dispatch(this._parent, this);
|
||||
this._parent.events.onAnimationComplete.dispatch(this._parent, this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
*/
|
||||
Phaser.AnimationManager = function (parent) {
|
||||
Phaser.AnimationManager = function (sprite) {
|
||||
|
||||
/**
|
||||
* Data contains animation frames.
|
||||
@@ -22,17 +22,18 @@ Phaser.AnimationManager = function (parent) {
|
||||
*/
|
||||
this.currentFrame = null;
|
||||
|
||||
this._parent = parent;
|
||||
this.sprite = sprite;
|
||||
|
||||
this.game = parent.game;
|
||||
this.game = sprite.game;
|
||||
|
||||
this._anims = {};
|
||||
|
||||
this.updateIfVisible = true;
|
||||
|
||||
};
|
||||
|
||||
Phaser.AnimationManager.prototype = {
|
||||
|
||||
updateIfVisible: true,
|
||||
|
||||
/**
|
||||
* Load animation frame data.
|
||||
@@ -68,12 +69,12 @@ Phaser.AnimationManager.prototype = {
|
||||
}
|
||||
|
||||
// Create the signals the AnimationManager will emit
|
||||
// if (this._parent.events.onAnimationStart == null)
|
||||
// {
|
||||
// this._parent.events.onAnimationStart = new Phaser.Signal();
|
||||
// this._parent.events.onAnimationComplete = new Phaser.Signal();
|
||||
// this._parent.events.onAnimationLoop = new Phaser.Signal();
|
||||
// }
|
||||
if (this.sprite.events.onAnimationStart == null)
|
||||
{
|
||||
this.sprite.events.onAnimationStart = new Phaser.Signal();
|
||||
this.sprite.events.onAnimationComplete = new Phaser.Signal();
|
||||
this.sprite.events.onAnimationLoop = new Phaser.Signal();
|
||||
}
|
||||
|
||||
if (frames == null)
|
||||
{
|
||||
@@ -93,10 +94,10 @@ Phaser.AnimationManager.prototype = {
|
||||
frames = this._frameData.getFrameIndexesByName(frames);
|
||||
}
|
||||
|
||||
this._anims[name] = new Phaser.Animation(this.game, this._parent, this._frameData, name, frames, frameRate, loop);
|
||||
this._anims[name] = new Phaser.Animation(this.game, this.sprite, this._frameData, name, frames, frameRate, loop);
|
||||
this.currentAnim = this._anims[name];
|
||||
this.currentFrame = this.currentAnim.currentFrame;
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
|
||||
return this._anims[name];
|
||||
|
||||
@@ -181,7 +182,7 @@ Phaser.AnimationManager.prototype = {
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
if (this.updateIfVisible && this._parent.visible == false)
|
||||
if (this.updateIfVisible && this.sprite.visible == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -189,7 +190,7 @@ Phaser.AnimationManager.prototype = {
|
||||
if (this.currentAnim && this.currentAnim.update() == true)
|
||||
{
|
||||
this.currentFrame = this.currentAnim.currentFrame;
|
||||
this._parent.currentFrame = this.currentFrame;
|
||||
this.sprite.currentFrame = this.currentFrame;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -261,8 +262,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrame(value);
|
||||
this._frameIndex = value;
|
||||
this._parent.currentFrame = this.currentFrame;
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
this.sprite.currentFrame = this.currentFrame;
|
||||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
|
||||
},
|
||||
@@ -288,8 +289,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrameByName(value);
|
||||
this._frameIndex = this.currentFrame.index;
|
||||
this._parent.currentFrame = this.currentFrame;
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
this.sprite.currentFrame = this.currentFrame;
|
||||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+32
-46
@@ -10,133 +10,119 @@
|
||||
*/
|
||||
Phaser.Animation.Frame = function (x, y, width, height, name, uuid) {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.sourceSizeW = width;
|
||||
this.sourceSizeH = height;
|
||||
this.centerX = Math.floor(width / 2);
|
||||
this.centerY = Math.floor(height / 2);
|
||||
this.name = name;
|
||||
this.uuid = uuid;
|
||||
this.distance = Phaser.Math.distance(0, 0, width, height);
|
||||
|
||||
};
|
||||
|
||||
Phaser.Animation.Frame.prototype = {
|
||||
|
||||
/**
|
||||
* A link to the PIXI.TextureCache entry
|
||||
*/
|
||||
uuid: '',
|
||||
|
||||
/**
|
||||
* X position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
x: 0,
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* Y position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
y: 0,
|
||||
this.y = y;
|
||||
|
||||
/**
|
||||
* Width of the frame.
|
||||
* @type {number}
|
||||
*/
|
||||
width: 0,
|
||||
this.width = width;
|
||||
|
||||
/**
|
||||
* Height of the frame.
|
||||
* @type {number}
|
||||
*/
|
||||
height: 0,
|
||||
this.height = height;
|
||||
|
||||
/**
|
||||
* center X position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
centerX: 0,
|
||||
this.centerX = Math.floor(width / 2);
|
||||
|
||||
/**
|
||||
* center Y position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
centerY: 0,
|
||||
|
||||
/**
|
||||
* The distance from the top left to the bottom-right of this Frame.
|
||||
* @type {number}
|
||||
*/
|
||||
distance: 0,
|
||||
this.centerY = Math.floor(height / 2);
|
||||
|
||||
/**
|
||||
* Useful for Sprite Sheets.
|
||||
* @type {number}
|
||||
*/
|
||||
index: 0,
|
||||
this.index = 0;
|
||||
|
||||
/**
|
||||
* Useful for Texture Atlas files. (is set to the filename value)
|
||||
*/
|
||||
name: '',
|
||||
this.name = name;
|
||||
|
||||
/**
|
||||
* A link to the PIXI.TextureCache entry
|
||||
*/
|
||||
this.uuid = uuid;
|
||||
|
||||
/**
|
||||
* The distance from the top left to the bottom-right of this Frame.
|
||||
* @type {number}
|
||||
*/
|
||||
this.distance = Phaser.Math.distance(0, 0, width, height);
|
||||
|
||||
/**
|
||||
* Rotated? (not yet implemented)
|
||||
*/
|
||||
rotated: false,
|
||||
this.rotated = false;
|
||||
|
||||
/**
|
||||
* Either cw or ccw, rotation is always 90 degrees.
|
||||
*/
|
||||
rotationDirection: 'cw',
|
||||
this.rotationDirection = 'cw';
|
||||
|
||||
/**
|
||||
* Was it trimmed when packed?
|
||||
* @type {bool}
|
||||
*/
|
||||
trimmed: false,
|
||||
|
||||
// The coordinates of the trimmed sprite inside the original sprite
|
||||
this.trimmed = false;
|
||||
|
||||
/**
|
||||
* Width of the original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
sourceSizeW: 0,
|
||||
this.sourceSizeW = width;
|
||||
|
||||
/**
|
||||
* Height of the original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
sourceSizeH: 0,
|
||||
this.sourceSizeH = height;
|
||||
|
||||
/**
|
||||
* X position of the trimmed sprite inside original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
spriteSourceSizeX: 0,
|
||||
this.spriteSourceSizeX = 0;
|
||||
|
||||
/**
|
||||
* Y position of the trimmed sprite inside original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
spriteSourceSizeY: 0,
|
||||
this.spriteSourceSizeY = 0;
|
||||
|
||||
/**
|
||||
* Width of the trimmed sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
spriteSourceSizeW: 0,
|
||||
this.spriteSourceSizeW = 0;
|
||||
|
||||
/**
|
||||
* Height of the trimmed sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
spriteSourceSizeH: 0,
|
||||
this.spriteSourceSizeH = 0;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Animation.Frame.prototype = {
|
||||
|
||||
/**
|
||||
* Set trim of the frame.
|
||||
|
||||
+18
-17
@@ -10,26 +10,23 @@
|
||||
*/
|
||||
Phaser.Animation.FrameData = function () {
|
||||
|
||||
/**
|
||||
* Local frame container.
|
||||
* @type {Phaser.Frame[]}
|
||||
* @private
|
||||
*/
|
||||
this._frames = [];
|
||||
|
||||
/**
|
||||
* Local frameName<->index container.
|
||||
* @private
|
||||
*/
|
||||
this._frameNames = [];
|
||||
|
||||
};
|
||||
|
||||
Phaser.Animation.FrameData.prototype = {
|
||||
|
||||
/**
|
||||
* Local frame container.
|
||||
* @type {Phaser.Frame[]}
|
||||
* @private
|
||||
*/
|
||||
_frames: [],
|
||||
|
||||
/**
|
||||
* Local frameName<->index container.
|
||||
* @private
|
||||
*/
|
||||
_frameNames: [],
|
||||
|
||||
/**
|
||||
* Add a new frame.
|
||||
* @param frame {Frame} The frame you want to add.
|
||||
@@ -41,7 +38,8 @@ Phaser.Animation.FrameData.prototype = {
|
||||
|
||||
this._frames.push(frame);
|
||||
|
||||
if (frame.name !== '') {
|
||||
if (frame.name !== '')
|
||||
{
|
||||
this._frameNames[frame.name] = frame.index;
|
||||
}
|
||||
|
||||
@@ -56,7 +54,8 @@ Phaser.Animation.FrameData.prototype = {
|
||||
*/
|
||||
getFrame: function (index) {
|
||||
|
||||
if (this._frames[index]) {
|
||||
if (this._frames[index])
|
||||
{
|
||||
return this._frames[index];
|
||||
}
|
||||
|
||||
@@ -71,7 +70,8 @@ Phaser.Animation.FrameData.prototype = {
|
||||
*/
|
||||
getFrameByName: function (name) {
|
||||
|
||||
if (this._frameNames[name] !== '') {
|
||||
if (this._frameNames[name] !== '')
|
||||
{
|
||||
return this._frames[this._frameNames[name]];
|
||||
}
|
||||
|
||||
@@ -86,7 +86,8 @@ Phaser.Animation.FrameData.prototype = {
|
||||
*/
|
||||
checkFrameName: function (name) {
|
||||
|
||||
if (this._frameNames[name] == null) {
|
||||
if (this._frameNames[name] == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+23
-29
@@ -14,9 +14,32 @@ Phaser.Camera = function (game, id, x, y, width, height) {
|
||||
// The view into the world we wish to render (by default the game dimensions)
|
||||
// The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render
|
||||
// Objects outside of this view are not rendered (unless set to ignore the Camera, i.e. UI?)
|
||||
|
||||
/**
|
||||
* Camera view.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
this.view = new Phaser.Rectangle(x, y, width, height);
|
||||
|
||||
this.screenView = new Phaser.Rectangle(x, y, width, height);
|
||||
|
||||
/**
|
||||
* Sprite moving inside this Rectangle will not cause camera moving.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
this.deadzone = null;
|
||||
|
||||
/**
|
||||
* Whether this camera is visible or not. (default is true)
|
||||
* @type {bool}
|
||||
*/
|
||||
this.visible = true;
|
||||
|
||||
/**
|
||||
* If the camera is tracking a Sprite, this is a reference to it, otherwise null
|
||||
* @type {Sprite}
|
||||
*/
|
||||
this.target = null;
|
||||
|
||||
};
|
||||
|
||||
@@ -28,35 +51,6 @@ Phaser.Camera.FOLLOW_TOPDOWN_TIGHT = 3;
|
||||
|
||||
Phaser.Camera.prototype = {
|
||||
|
||||
game: null,
|
||||
world: null,
|
||||
|
||||
id: 0,
|
||||
|
||||
/**
|
||||
* Camera view.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
view: null,
|
||||
|
||||
/**
|
||||
* Sprite moving inside this Rectangle will not cause camera moving.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
deadzone: null,
|
||||
|
||||
/**
|
||||
* Whether this camera is visible or not. (default is true)
|
||||
* @type {bool}
|
||||
*/
|
||||
visible: true,
|
||||
|
||||
/**
|
||||
* If the camera is tracking a Sprite, this is a reference to it, otherwise null
|
||||
* @type {Sprite}
|
||||
*/
|
||||
target: null,
|
||||
|
||||
/**
|
||||
* Tells this camera which sprite to follow.
|
||||
* @param target {Sprite} The object you want the camera to track. Set to null to not follow anything.
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
Phaser.LinkedList = function () {
|
||||
|
||||
this.next = null;
|
||||
this.prev = null;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.total = 0;
|
||||
|
||||
};
|
||||
|
||||
Phaser.LinkedList.prototype = {
|
||||
|
||||
next: null,
|
||||
prev: null,
|
||||
first: null,
|
||||
last: null,
|
||||
total: 0,
|
||||
sprite: { name: 'HD' },
|
||||
|
||||
add: function (child) {
|
||||
|
||||
|
||||
@@ -36,12 +36,6 @@ Phaser.Stage = function (game, width, height) {
|
||||
|
||||
Phaser.Stage.prototype = {
|
||||
|
||||
_onChange: null,
|
||||
|
||||
canvas: null,
|
||||
bounds: null,
|
||||
offset: null,
|
||||
|
||||
boot: function () {
|
||||
|
||||
Phaser.Canvas.getOffset(this.canvas, this.offset);
|
||||
|
||||
+25
-7
@@ -11,6 +11,22 @@
|
||||
*/
|
||||
|
||||
Phaser.State = function () {
|
||||
|
||||
this.game = null;
|
||||
this.add = null;
|
||||
this.camera = null;
|
||||
this.cache = null;
|
||||
this.input = null;
|
||||
this.load = null;
|
||||
// this.math = null;
|
||||
this.sound = null;
|
||||
this.stage = null;
|
||||
this.time = null;
|
||||
this.tweens = null;
|
||||
this.world = null;
|
||||
this.particles = null;
|
||||
this.physics = null;
|
||||
|
||||
};
|
||||
|
||||
Phaser.State.prototype = {
|
||||
@@ -18,17 +34,19 @@ Phaser.State.prototype = {
|
||||
link: function (game) {
|
||||
|
||||
this.game = game;
|
||||
// this.add = game.add;
|
||||
// this.camera = game.camera;
|
||||
this.add = game.add;
|
||||
this.camera = game.camera;
|
||||
this.cache = game.cache;
|
||||
// this.input = game.input;
|
||||
this.input = game.input;
|
||||
this.load = game.load;
|
||||
this.math = game.math;
|
||||
// this.sound = game.sound;
|
||||
// this.stage = game.stage;
|
||||
// this.math = game.math;
|
||||
this.sound = game.sound;
|
||||
this.stage = game.stage;
|
||||
this.time = game.time;
|
||||
this.tweens = game.tweens;
|
||||
// this.world = game.world;
|
||||
this.world = game.world;
|
||||
this.particles = game.particles;
|
||||
this.physics = game.physics;
|
||||
|
||||
},
|
||||
|
||||
|
||||
+4
-4
@@ -3,15 +3,15 @@ Phaser.World = function (game) {
|
||||
this.game = game;
|
||||
|
||||
this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height);
|
||||
|
||||
this.camera = null;
|
||||
|
||||
this.currentRenderOrderID = 0;
|
||||
|
||||
};
|
||||
|
||||
Phaser.World.prototype = {
|
||||
|
||||
bounds: null,
|
||||
camera: null,
|
||||
|
||||
currentRenderOrderID: 0,
|
||||
|
||||
boot: function () {
|
||||
|
||||
|
||||
@@ -18,4 +18,8 @@ Phaser.Events = function (sprite) {
|
||||
this.onDragStart = null;
|
||||
this.onDragStop = null;
|
||||
|
||||
this.onAnimationStart = null;
|
||||
this.onAnimationComplete = null;
|
||||
this.onAnimationLoop = null;
|
||||
|
||||
};
|
||||
+15
-9
@@ -11,28 +11,34 @@
|
||||
**/
|
||||
Phaser.Circle = function (x, y, diameter) {
|
||||
|
||||
if (typeof x === "undefined") { x = 0; }
|
||||
if (typeof y === "undefined") { y = 0; }
|
||||
if (typeof diameter === "undefined") { diameter = 0; }
|
||||
|
||||
this._diameter = 0;
|
||||
this._radius = 0;
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
diameter = diameter || 0;
|
||||
|
||||
/**
|
||||
* The x coordinate of the center of the circle
|
||||
* @property x
|
||||
* @type Number
|
||||
**/
|
||||
this.x = 0;
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* The y coordinate of the center of the circle
|
||||
* @property y
|
||||
* @type Number
|
||||
**/
|
||||
this.y = 0;
|
||||
this.y = y;
|
||||
|
||||
this.setTo(x, y, diameter);
|
||||
this._diameter = diameter;
|
||||
|
||||
if (diameter > 0)
|
||||
{
|
||||
this._radius = diameter * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._radius = 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@
|
||||
**/
|
||||
Phaser.Point = function (x, y) {
|
||||
|
||||
if (typeof x === "undefined") { x = 0; }
|
||||
if (typeof y === "undefined") { y = 0; }
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
@@ -48,34 +48,6 @@ Phaser.Rectangle = function (x, y, width, height) {
|
||||
|
||||
Phaser.Rectangle.prototype = {
|
||||
|
||||
/**
|
||||
* @property x
|
||||
* @type Number
|
||||
* @default 0
|
||||
*/
|
||||
x: 0,
|
||||
|
||||
/**
|
||||
* @property y
|
||||
* @type Number
|
||||
* @default 0
|
||||
*/
|
||||
y: 0,
|
||||
|
||||
/**
|
||||
* @property width
|
||||
* @type Number
|
||||
* @default 0
|
||||
*/
|
||||
width: 0,
|
||||
|
||||
/**
|
||||
* @property height
|
||||
* @type Number
|
||||
* @default 0
|
||||
*/
|
||||
height: 0,
|
||||
|
||||
/**
|
||||
* Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.
|
||||
* @method offset
|
||||
|
||||
@@ -6,6 +6,9 @@ Phaser.InputHandler = function (sprite) {
|
||||
this.enabled = false;
|
||||
|
||||
// Linked list references
|
||||
this.parent = null;
|
||||
this.next = null;
|
||||
this.prev = null;
|
||||
this.last = this;
|
||||
this.first = this;
|
||||
|
||||
@@ -55,16 +58,6 @@ Phaser.InputHandler = function (sprite) {
|
||||
|
||||
Phaser.InputHandler.prototype = {
|
||||
|
||||
game: null,
|
||||
sprite: null,
|
||||
|
||||
// Linked list references
|
||||
parent: null,
|
||||
next: null,
|
||||
prev: null,
|
||||
first: null,
|
||||
last: null,
|
||||
|
||||
start: function (priority, checkBody, useHandCursor) {
|
||||
|
||||
priority = priority || 0;
|
||||
|
||||
+180
-180
@@ -5,6 +5,181 @@
|
||||
*/
|
||||
Phaser.Pointer = function (game, id) {
|
||||
|
||||
/**
|
||||
* Local private variable to store the status of dispatching a hold event
|
||||
* @property _holdSent
|
||||
* @type {bool}
|
||||
* @private
|
||||
*/
|
||||
this._holdSent = false;
|
||||
|
||||
/**
|
||||
* Local private variable storing the short-term history of pointer movements
|
||||
* @property _history
|
||||
* @type {Array}
|
||||
* @private
|
||||
*/
|
||||
this._history = [];
|
||||
|
||||
/**
|
||||
* Local private variable storing the time at which the next history drop should occur
|
||||
* @property _lastDrop
|
||||
* @type {Number}
|
||||
* @private
|
||||
*/
|
||||
this._nextDrop = 0;
|
||||
|
||||
// Monitor events outside of a state reset loop
|
||||
this._stateReset = false;
|
||||
|
||||
/**
|
||||
* A Vector object containing the initial position when the Pointer was engaged with the screen.
|
||||
* @property positionDown
|
||||
* @type {Vec2}
|
||||
**/
|
||||
this.positionDown = null;
|
||||
|
||||
/**
|
||||
* A Vector object containing the current position of the Pointer on the screen.
|
||||
* @property position
|
||||
* @type {Vec2}
|
||||
**/
|
||||
this.position = null;
|
||||
|
||||
/**
|
||||
* A Circle object centered on the x/y screen coordinates of the Pointer.
|
||||
* Default size of 44px (Apple's recommended "finger tip" size)
|
||||
* @property circle
|
||||
* @type {Circle}
|
||||
**/
|
||||
this.circle = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property withinGame
|
||||
* @type {bool}
|
||||
*/
|
||||
this.withinGame = false;
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset
|
||||
* @property clientX
|
||||
* @type {Number}
|
||||
*/
|
||||
this.clientX = -1;
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset
|
||||
* @property clientY
|
||||
* @type {Number}
|
||||
*/
|
||||
this.clientY = -1;
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset
|
||||
* @property pageX
|
||||
* @type {Number}
|
||||
*/
|
||||
this.pageX = -1;
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the viewport in pixels, including any scroll offset
|
||||
* @property pageY
|
||||
* @type {Number}
|
||||
*/
|
||||
this.pageY = -1;
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the screen in pixels
|
||||
* @property screenX
|
||||
* @type {Number}
|
||||
*/
|
||||
this.screenX = -1;
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the screen in pixels
|
||||
* @property screenY
|
||||
* @type {Number}
|
||||
*/
|
||||
this.screenY = -1;
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size.
|
||||
* @property x
|
||||
* @type {Number}
|
||||
*/
|
||||
this.x = -1;
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size.
|
||||
* @property y
|
||||
* @type {Number}
|
||||
*/
|
||||
this.y = -1;
|
||||
|
||||
/**
|
||||
* If the Pointer is a mouse this is true, otherwise false
|
||||
* @property isMouse
|
||||
* @type {bool}
|
||||
**/
|
||||
this.isMouse = false;
|
||||
|
||||
/**
|
||||
* If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true
|
||||
* @property isDown
|
||||
* @type {bool}
|
||||
**/
|
||||
this.isDown = false;
|
||||
|
||||
/**
|
||||
* If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true
|
||||
* @property isUp
|
||||
* @type {bool}
|
||||
**/
|
||||
this.isUp = true;
|
||||
|
||||
/**
|
||||
* A timestamp representing when the Pointer first touched the touchscreen.
|
||||
* @property timeDown
|
||||
* @type {Number}
|
||||
**/
|
||||
this.timeDown = 0;
|
||||
|
||||
/**
|
||||
* A timestamp representing when the Pointer left the touchscreen.
|
||||
* @property timeUp
|
||||
* @type {Number}
|
||||
**/
|
||||
this.timeUp = 0;
|
||||
|
||||
/**
|
||||
* A timestamp representing when the Pointer was last tapped or clicked
|
||||
* @property previousTapTime
|
||||
* @type {Number}
|
||||
**/
|
||||
this.previousTapTime = 0;
|
||||
|
||||
/**
|
||||
* The total number of times this Pointer has been touched to the touchscreen
|
||||
* @property totalTouches
|
||||
* @type {Number}
|
||||
**/
|
||||
this.totalTouches = 0;
|
||||
|
||||
/**
|
||||
* The number of miliseconds since the last click
|
||||
* @property msSinceLastClick
|
||||
* @type {Number}
|
||||
**/
|
||||
this.msSinceLastClick = Number.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* The Game Object this Pointer is currently over / touching / dragging.
|
||||
* @property targetObject
|
||||
* @type {Any}
|
||||
**/
|
||||
this.targetObject = null;
|
||||
|
||||
this.game = game;
|
||||
this.id = id;
|
||||
|
||||
@@ -24,181 +199,6 @@ Phaser.Pointer = function (game, id) {
|
||||
|
||||
Phaser.Pointer.prototype = {
|
||||
|
||||
/**
|
||||
* Local private variable to store the status of dispatching a hold event
|
||||
* @property _holdSent
|
||||
* @type {bool}
|
||||
* @private
|
||||
*/
|
||||
_holdSent: false,
|
||||
|
||||
/**
|
||||
* Local private variable storing the short-term history of pointer movements
|
||||
* @property _history
|
||||
* @type {Array}
|
||||
* @private
|
||||
*/
|
||||
_history: [],
|
||||
|
||||
/**
|
||||
* Local private variable storing the time at which the next history drop should occur
|
||||
* @property _lastDrop
|
||||
* @type {Number}
|
||||
* @private
|
||||
*/
|
||||
_nextDrop: 0,
|
||||
|
||||
// Monitor events outside of a state reset loop
|
||||
_stateReset: false,
|
||||
|
||||
/**
|
||||
* A Vector object containing the initial position when the Pointer was engaged with the screen.
|
||||
* @property positionDown
|
||||
* @type {Vec2}
|
||||
**/
|
||||
positionDown: null,
|
||||
|
||||
/**
|
||||
* A Vector object containing the current position of the Pointer on the screen.
|
||||
* @property position
|
||||
* @type {Vec2}
|
||||
**/
|
||||
position: null,
|
||||
|
||||
/**
|
||||
* A Circle object centered on the x/y screen coordinates of the Pointer.
|
||||
* Default size of 44px (Apple's recommended "finger tip" size)
|
||||
* @property circle
|
||||
* @type {Circle}
|
||||
**/
|
||||
circle: null,
|
||||
|
||||
/**
|
||||
*
|
||||
* @property withinGame
|
||||
* @type {bool}
|
||||
*/
|
||||
withinGame: false,
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset
|
||||
* @property clientX
|
||||
* @type {Number}
|
||||
*/
|
||||
clientX: -1,
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset
|
||||
* @property clientY
|
||||
* @type {Number}
|
||||
*/
|
||||
clientY: -1,
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset
|
||||
* @property pageX
|
||||
* @type {Number}
|
||||
*/
|
||||
pageX: -1,
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the viewport in pixels, including any scroll offset
|
||||
* @property pageY
|
||||
* @type {Number}
|
||||
*/
|
||||
pageY: -1,
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the screen in pixels
|
||||
* @property screenX
|
||||
* @type {Number}
|
||||
*/
|
||||
screenX: -1,
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the screen in pixels
|
||||
* @property screenY
|
||||
* @type {Number}
|
||||
*/
|
||||
screenY: -1,
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size.
|
||||
* @property x
|
||||
* @type {Number}
|
||||
*/
|
||||
x: -1,
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size.
|
||||
* @property y
|
||||
* @type {Number}
|
||||
*/
|
||||
y: -1,
|
||||
|
||||
/**
|
||||
* If the Pointer is a mouse this is true, otherwise false
|
||||
* @property isMouse
|
||||
* @type {bool}
|
||||
**/
|
||||
isMouse: false,
|
||||
|
||||
/**
|
||||
* If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true
|
||||
* @property isDown
|
||||
* @type {bool}
|
||||
**/
|
||||
isDown: false,
|
||||
|
||||
/**
|
||||
* If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true
|
||||
* @property isUp
|
||||
* @type {bool}
|
||||
**/
|
||||
isUp: true,
|
||||
|
||||
/**
|
||||
* A timestamp representing when the Pointer first touched the touchscreen.
|
||||
* @property timeDown
|
||||
* @type {Number}
|
||||
**/
|
||||
timeDown: 0,
|
||||
|
||||
/**
|
||||
* A timestamp representing when the Pointer left the touchscreen.
|
||||
* @property timeUp
|
||||
* @type {Number}
|
||||
**/
|
||||
timeUp: 0,
|
||||
|
||||
/**
|
||||
* A timestamp representing when the Pointer was last tapped or clicked
|
||||
* @property previousTapTime
|
||||
* @type {Number}
|
||||
**/
|
||||
previousTapTime: 0,
|
||||
|
||||
/**
|
||||
* The total number of times this Pointer has been touched to the touchscreen
|
||||
* @property totalTouches
|
||||
* @type {Number}
|
||||
**/
|
||||
totalTouches: 0,
|
||||
|
||||
/**
|
||||
* The number of miliseconds since the last click
|
||||
* @property msSinceLastClick
|
||||
* @type {Number}
|
||||
**/
|
||||
msSinceLastClick: Number.MAX_VALUE,
|
||||
|
||||
/**
|
||||
* The Game Object this Pointer is currently over / touching / dragging.
|
||||
* @property targetObject
|
||||
* @type {Any}
|
||||
**/
|
||||
targetObject: null,
|
||||
|
||||
/**
|
||||
* Called when the Pointer is pressed onto the touchscreen
|
||||
* @method start
|
||||
@@ -215,11 +215,11 @@ Phaser.Pointer.prototype = {
|
||||
}
|
||||
|
||||
// Fix to stop rogue browser plugins from blocking the visibility state event
|
||||
// if (this.game.paused == true && this.game.stage.scale.incorrectOrientation == false)
|
||||
// {
|
||||
// this.game.stage.resumeGame();
|
||||
// return this;
|
||||
// }
|
||||
if (this.game.paused == true && this.game.stage.scale.incorrectOrientation == false)
|
||||
{
|
||||
this.game.paused = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
this._history.length = 0;
|
||||
this.active = true;
|
||||
|
||||
+24
-30
@@ -11,10 +11,34 @@
|
||||
*/
|
||||
Phaser.Cache = function (game) {
|
||||
|
||||
/**
|
||||
* Local reference to Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* Canvas key-value container.
|
||||
* @type {object}
|
||||
* @private
|
||||
*/
|
||||
this._canvases = {};
|
||||
|
||||
/**
|
||||
* Image key-value container.
|
||||
* @type {object}
|
||||
*/
|
||||
this._images = {};
|
||||
|
||||
/**
|
||||
* Sound key-value container.
|
||||
* @type {object}
|
||||
*/
|
||||
this._sounds = {};
|
||||
|
||||
/**
|
||||
* Text key-value container.
|
||||
* @type {object}
|
||||
*/
|
||||
this._text = {};
|
||||
|
||||
this.addDefaultImage();
|
||||
@@ -23,36 +47,6 @@ Phaser.Cache = function (game) {
|
||||
|
||||
Phaser.Cache.prototype = {
|
||||
|
||||
/**
|
||||
* Local reference to Game.
|
||||
*/
|
||||
game: null,
|
||||
|
||||
/**
|
||||
* Canvas key-value container.
|
||||
* @type {object}
|
||||
* @private
|
||||
*/
|
||||
_canvases: {},
|
||||
|
||||
/**
|
||||
* Image key-value container.
|
||||
* @type {object}
|
||||
*/
|
||||
_images: {},
|
||||
|
||||
/**
|
||||
* Sound key-value container.
|
||||
* @type {object}
|
||||
*/
|
||||
_sounds: {},
|
||||
|
||||
/**
|
||||
* Text key-value container.
|
||||
* @type {object}
|
||||
*/
|
||||
_text: {},
|
||||
|
||||
/**
|
||||
* Add a new canvas.
|
||||
* @param key {string} Asset key for this canvas.
|
||||
|
||||
+83
-86
@@ -6,10 +6,74 @@
|
||||
*/
|
||||
Phaser.Loader = function (game) {
|
||||
|
||||
/**
|
||||
* Local reference to Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* Array stores assets keys. So you can get that asset by its unique key.
|
||||
*/
|
||||
this._keys = [];
|
||||
|
||||
/**
|
||||
* Contains all the assets file infos.
|
||||
*/
|
||||
this._fileList = {};
|
||||
|
||||
/**
|
||||
* Indicates assets loading progress. (from 0 to 100)
|
||||
* @type {number}
|
||||
*/
|
||||
this._progressChunk = 0;
|
||||
|
||||
/**
|
||||
* An XMLHttpRequest object used for loading text and audio data
|
||||
* @type {XMLHttpRequest}
|
||||
*/
|
||||
this._xhr = new XMLHttpRequest();
|
||||
|
||||
/**
|
||||
* Length of assets queue.
|
||||
* @type {number}
|
||||
*/
|
||||
this.queueSize = 0;
|
||||
|
||||
/**
|
||||
* True if the Loader is in the process of loading the queue.
|
||||
* @type {bool}
|
||||
*/
|
||||
this.isLoading = false;
|
||||
|
||||
/**
|
||||
* True if all assets in the queue have finished loading.
|
||||
* @type {bool}
|
||||
*/
|
||||
this.hasLoaded = false;
|
||||
|
||||
/**
|
||||
* The Load progress percentage value (from 0 to 100)
|
||||
* @type {number}
|
||||
*/
|
||||
this.progress = 0;
|
||||
|
||||
/**
|
||||
* The crossOrigin value applied to loaded images
|
||||
* @type {string}
|
||||
*/
|
||||
this.crossOrigin = '';
|
||||
|
||||
/**
|
||||
* If you want to append a URL before the path of any asset you can set this here.
|
||||
* Useful if you need to allow an asset url to be configured outside of the game code.
|
||||
* MUST have / on the end of it!
|
||||
* @type {string}
|
||||
*/
|
||||
this.baseURL = '';
|
||||
|
||||
/**
|
||||
* Event Signals
|
||||
*/
|
||||
this.onFileComplete = new Phaser.Signal;
|
||||
this.onFileError = new Phaser.Signal;
|
||||
this.onLoadStart = new Phaser.Signal;
|
||||
@@ -26,79 +90,6 @@ Phaser.Loader.TEXTURE_ATLAS_XML_STARLING = 2;
|
||||
|
||||
Phaser.Loader.prototype = {
|
||||
|
||||
/**
|
||||
* Local reference to Game.
|
||||
*/
|
||||
game: null,
|
||||
|
||||
/**
|
||||
* Array stores assets keys. So you can get that asset by its unique key.
|
||||
*/
|
||||
_keys: [],
|
||||
|
||||
/**
|
||||
* Contains all the assets file infos.
|
||||
*/
|
||||
_fileList: {},
|
||||
|
||||
/**
|
||||
* Indicates assets loading progress. (from 0 to 100)
|
||||
* @type {number}
|
||||
*/
|
||||
_progressChunk: 0,
|
||||
|
||||
/**
|
||||
* An XMLHttpRequest object used for loading text and audio data
|
||||
* @type {XMLHttpRequest}
|
||||
*/
|
||||
_xhr: null,
|
||||
|
||||
/**
|
||||
* Length of assets queue.
|
||||
* @type {number}
|
||||
*/
|
||||
queueSize: 0,
|
||||
|
||||
/**
|
||||
* True if the Loader is in the process of loading the queue.
|
||||
* @type {bool}
|
||||
*/
|
||||
isLoading: false,
|
||||
|
||||
/**
|
||||
* True if all assets in the queue have finished loading.
|
||||
* @type {bool}
|
||||
*/
|
||||
hasLoaded: false,
|
||||
|
||||
/**
|
||||
* The Load progress percentage value (from 0 to 100)
|
||||
* @type {number}
|
||||
*/
|
||||
progress: 0,
|
||||
|
||||
/**
|
||||
* The crossOrigin value applied to loaded images
|
||||
* @type {string}
|
||||
*/
|
||||
crossOrigin: '',
|
||||
|
||||
/**
|
||||
* If you want to append a URL before the path of any asset you can set this here.
|
||||
* Useful if you need to allow an asset url to be configured outside of the game code.
|
||||
* MUST have / on the end of it!
|
||||
* @type {string}
|
||||
*/
|
||||
baseURL: '',
|
||||
|
||||
/**
|
||||
* Event Signals
|
||||
*/
|
||||
onFileComplete: null,
|
||||
onFileError: null,
|
||||
onLoadStart: null,
|
||||
onLoadComplete: null,
|
||||
|
||||
/**
|
||||
* Check whether asset exists with a specific key.
|
||||
* @param key {string} Key of the asset you want to check.
|
||||
@@ -106,9 +97,12 @@ Phaser.Loader.prototype = {
|
||||
*/
|
||||
checkKeyExists: function (key) {
|
||||
|
||||
if (this._fileList[key]) {
|
||||
if (this._fileList[key])
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -118,8 +112,10 @@ Phaser.Loader.prototype = {
|
||||
* Reset loader, this will remove all loaded assets.
|
||||
*/
|
||||
reset: function () {
|
||||
|
||||
this.queueSize = 0;
|
||||
this.isLoading = false;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -136,12 +132,12 @@ Phaser.Loader.prototype = {
|
||||
loaded: false
|
||||
};
|
||||
|
||||
if (typeof properties !== "undefined") {
|
||||
|
||||
for (var prop in properties) {
|
||||
if (typeof properties !== "undefined")
|
||||
{
|
||||
for (var prop in properties)
|
||||
{
|
||||
entry[prop] = properties[prop];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this._fileList[key] = entry;
|
||||
@@ -162,7 +158,8 @@ Phaser.Loader.prototype = {
|
||||
|
||||
if (typeof overwrite === "undefined") { overwrite = false; }
|
||||
|
||||
if (overwrite || this.checkKeyExists(key) == false) {
|
||||
if (overwrite || this.checkKeyExists(key) == false)
|
||||
{
|
||||
this.addToFileList('image', key, url);
|
||||
}
|
||||
|
||||
@@ -221,21 +218,21 @@ Phaser.Loader.prototype = {
|
||||
},
|
||||
|
||||
atlasJSONArray: function (key, textureURL, atlasURL, atlasData) {
|
||||
if (typeof atlasURL === "undefined") { atlasURL = null; }
|
||||
if (typeof atlasData === "undefined") { atlasData = null; }
|
||||
|
||||
this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY);
|
||||
|
||||
},
|
||||
|
||||
atlasJSONHash: function (key, textureURL, atlasURL, atlasData) {
|
||||
if (typeof atlasURL === "undefined") { atlasURL = null; }
|
||||
if (typeof atlasData === "undefined") { atlasData = null; }
|
||||
|
||||
this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
|
||||
|
||||
},
|
||||
|
||||
atlasXML: function (key, textureURL, atlasURL, atlasData) {
|
||||
if (typeof atlasURL === "undefined") { atlasURL = null; }
|
||||
if (typeof atlasData === "undefined") { atlasData = null; }
|
||||
|
||||
this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+7
-17
@@ -3,6 +3,13 @@ Phaser.Sound = function (game, key, volume, loop) {
|
||||
volume = volume || 1;
|
||||
loop = loop || false;
|
||||
|
||||
this.game = game;
|
||||
this.name = '';
|
||||
this.key = key;
|
||||
this.loop = loop;
|
||||
this._volume = volume;
|
||||
this.markers = {};
|
||||
|
||||
/**
|
||||
* Reference to AudioContext instance.
|
||||
*/
|
||||
@@ -15,9 +22,6 @@ Phaser.Sound = function (game, key, volume, loop) {
|
||||
|
||||
this._muted = false;
|
||||
|
||||
this.name = '';
|
||||
this.markers = {};
|
||||
|
||||
this.autoplay = false;
|
||||
this.totalDuration = 0;
|
||||
this.startTime = 0;
|
||||
@@ -30,20 +34,6 @@ Phaser.Sound = function (game, key, volume, loop) {
|
||||
this.pendingPlayback = false;
|
||||
this.override = false;
|
||||
|
||||
this.onDecoded = null;
|
||||
this.onPlay = null;
|
||||
this.onPause = null;
|
||||
this.onResume = null;
|
||||
this.onLoop = null;
|
||||
this.onStop = null;
|
||||
this.onMute = null;
|
||||
this.onMarkerComplete = null;
|
||||
|
||||
this.game = game;
|
||||
this.key = key;
|
||||
this._volume = volume;
|
||||
this.loop = loop;
|
||||
|
||||
this.usingWebAudio = this.game.sound.usingWebAudio;
|
||||
this.usingAudioTag = this.game.sound.usingAudioTag;
|
||||
|
||||
|
||||
+15
-18
@@ -7,29 +7,26 @@ Phaser.SoundManager = function (game) {
|
||||
this.game = game;
|
||||
|
||||
this.onSoundDecode = new Phaser.Signal;
|
||||
|
||||
this._muted = false;
|
||||
this._unlockSource = null;
|
||||
this._volume = 1;
|
||||
this._muted = false;
|
||||
this._sounds = [];
|
||||
|
||||
this.context = null;
|
||||
this.usingWebAudio = true;
|
||||
this.usingAudioTag = false;
|
||||
this.noAudio = false;
|
||||
|
||||
this.touchLocked = false;
|
||||
|
||||
this.channels = 32;
|
||||
|
||||
};
|
||||
|
||||
Phaser.SoundManager.prototype = {
|
||||
|
||||
game: null,
|
||||
|
||||
_muted: false,
|
||||
_unlockSource: null,
|
||||
_volume: 1,
|
||||
_muted: false,
|
||||
_sounds: [],
|
||||
|
||||
context: null,
|
||||
usingWebAudio: true,
|
||||
usingAudioTag: false,
|
||||
noAudio: false,
|
||||
|
||||
touchLocked: false,
|
||||
onSoundDecode: null,
|
||||
|
||||
channels: 32,
|
||||
|
||||
boot: function () {
|
||||
|
||||
if (this.game.device.iOS && this.game.device.webAudio == false)
|
||||
|
||||
+24
-28
@@ -15,21 +15,12 @@
|
||||
*/
|
||||
Phaser.Time = function (game) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
// this.game.onPause.add(this.gamePaused, this);
|
||||
// this.game.onResume.add(this.gameResumed, this);
|
||||
|
||||
};
|
||||
|
||||
Phaser.Time.prototype = {
|
||||
|
||||
/**
|
||||
* A reference to the currently running Game.
|
||||
* @property game
|
||||
* @type {Phaser.Game}
|
||||
*/
|
||||
game: null,
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* The time at which the Game instance started.
|
||||
@@ -37,7 +28,7 @@ Phaser.Time.prototype = {
|
||||
* @private
|
||||
* @type {Number}
|
||||
*/
|
||||
_started: 0,
|
||||
this._started = 0;
|
||||
|
||||
/**
|
||||
* The time (in ms) that the last second counter ticked over.
|
||||
@@ -45,7 +36,7 @@ Phaser.Time.prototype = {
|
||||
* @private
|
||||
* @type {Number}
|
||||
*/
|
||||
_timeLastSecond: 0,
|
||||
this._timeLastSecond = 0;
|
||||
|
||||
/**
|
||||
* The time the game started being paused.
|
||||
@@ -53,7 +44,7 @@ Phaser.Time.prototype = {
|
||||
* @private
|
||||
* @type {Number}
|
||||
*/
|
||||
_pauseStarted: 0,
|
||||
this._pauseStarted = 0;
|
||||
|
||||
/**
|
||||
* The elapsed time calculated for the physics motion updates.
|
||||
@@ -61,7 +52,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
physicsElapsed: 0,
|
||||
this.physicsElapsed = 0;
|
||||
|
||||
/**
|
||||
* Game time counter.
|
||||
@@ -69,7 +60,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
time: 0,
|
||||
this.time = 0;
|
||||
|
||||
/**
|
||||
* Records how long the game has been paused for. Is reset each time the game pauses.
|
||||
@@ -77,7 +68,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
pausedTime: 0,
|
||||
this.pausedTime = 0;
|
||||
|
||||
/**
|
||||
* The time right now.
|
||||
@@ -85,7 +76,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
now: 0,
|
||||
this.now = 0;
|
||||
|
||||
/**
|
||||
* Elapsed time since the last frame.
|
||||
@@ -93,7 +84,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
elapsed: 0,
|
||||
this.elapsed = 0;
|
||||
|
||||
/**
|
||||
* Frames per second.
|
||||
@@ -101,7 +92,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
fps: 0,
|
||||
this.fps = 0;
|
||||
|
||||
/**
|
||||
* The lowest rate the fps has dropped to.
|
||||
@@ -109,7 +100,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
fpsMin: 1000,
|
||||
this.fpsMin = 1000;
|
||||
|
||||
/**
|
||||
* The highest rate the fps has reached (usually no higher than 60fps).
|
||||
@@ -117,7 +108,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
fpsMax: 0,
|
||||
this.fpsMax = 0;
|
||||
|
||||
/**
|
||||
* The minimum amount of time the game has taken between two frames.
|
||||
@@ -125,7 +116,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
msMin: 1000,
|
||||
this.msMin = 1000;
|
||||
|
||||
/**
|
||||
* The maximum amount of time the game has taken between two frames.
|
||||
@@ -133,7 +124,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
msMax: 0,
|
||||
this.msMax = 0;
|
||||
|
||||
/**
|
||||
* The number of frames record in the last second.
|
||||
@@ -141,7 +132,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
frames: 0,
|
||||
this.frames = 0;
|
||||
|
||||
/**
|
||||
* Records how long the game was paused for in miliseconds.
|
||||
@@ -149,7 +140,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
pauseDuration: 0,
|
||||
this.pauseDuration = 0;
|
||||
|
||||
/**
|
||||
* The value that setTimeout needs to work out when to next update
|
||||
@@ -157,7 +148,7 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
timeToCall: 0,
|
||||
this.timeToCall = 0;
|
||||
|
||||
/**
|
||||
* Internal value used by timeToCall as part of the setTimeout loop
|
||||
@@ -165,7 +156,11 @@ Phaser.Time.prototype = {
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
lastTime: 0,
|
||||
this.lastTime = 0;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Time.prototype = {
|
||||
|
||||
/**
|
||||
* The number of seconds that have elapsed since the game was started.
|
||||
@@ -208,7 +203,8 @@ Phaser.Time.prototype = {
|
||||
this.physicsElapsed = 1.0 * (this.elapsed / 1000);
|
||||
|
||||
// Paused?
|
||||
if (this.game.paused) {
|
||||
if (this.game.paused)
|
||||
{
|
||||
this.pausedTime = this.now - this._pauseStarted;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,22 +55,11 @@ Phaser.TweenManager.prototype = {
|
||||
* Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
|
||||
*
|
||||
* @param obj {object} Object the tween will be run on.
|
||||
* @param [localReference] {bool} If true the tween will be stored in the object.tween property so long as it exists. If already set it'll be over-written.
|
||||
* @return {Phaser.Tween} The newly created tween object.
|
||||
*/
|
||||
create: function (object, localReference) {
|
||||
create: function (object) {
|
||||
|
||||
localReference = localReference || false;
|
||||
|
||||
if (localReference)
|
||||
{
|
||||
object['tween'] = new Phaser.Tween(object, this.game);
|
||||
return object['tween'];
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Phaser.Tween(object, this.game);
|
||||
}
|
||||
return new Phaser.Tween(object, this.game);
|
||||
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user