mirror of
https://github.com/wassname/phaser.git
synced 2026-06-29 16:30:29 +08:00
Lots of updates across input, rendering and grouping
This commit is contained in:
@@ -34,6 +34,7 @@ module Phaser {
|
||||
* Local private reference to game.
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* Local private reference to its owner sprite.
|
||||
*/
|
||||
@@ -43,11 +44,13 @@ module Phaser {
|
||||
* Animation key-value container.
|
||||
*/
|
||||
private _anims: {};
|
||||
|
||||
/**
|
||||
* Index of current frame.
|
||||
* @type {number}
|
||||
*/
|
||||
private _frameIndex: number;
|
||||
|
||||
/**
|
||||
* Data contains animation frames.
|
||||
* @type {FrameData}
|
||||
@@ -58,6 +61,7 @@ module Phaser {
|
||||
* Keeps track of the current animation being played.
|
||||
*/
|
||||
public currentAnim: Animation;
|
||||
|
||||
/**
|
||||
* Keeps track of the current frame of animation.
|
||||
*/
|
||||
|
||||
+14
-2
@@ -23,6 +23,8 @@ module Phaser {
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
this.isGroup = false;
|
||||
this.ignoreGlobalUpdate = false;
|
||||
this.ignoreGlobalRender = false;
|
||||
this.ignoreDrawDebug = false;
|
||||
|
||||
}
|
||||
@@ -70,6 +72,16 @@ module Phaser {
|
||||
*/
|
||||
public alive: bool;
|
||||
|
||||
/**
|
||||
* Setting this to true will prevent the object from being updated during the main game loop (you will have to call update on it yourself)
|
||||
*/
|
||||
public ignoreGlobalUpdate: bool;
|
||||
|
||||
/**
|
||||
* Setting this to true will prevent the object from being rendered during the main game loop (you will have to call render on it yourself)
|
||||
*/
|
||||
public ignoreGlobalRender: bool;
|
||||
|
||||
/**
|
||||
* Setting this to true will prevent the object from appearing
|
||||
* when the visual debug mode in the debugger overlay is toggled on.
|
||||
@@ -93,7 +105,7 @@ module Phaser {
|
||||
* Override this to update your class's position and appearance.
|
||||
* This is where most of your game rules and behavioral code will go.
|
||||
*/
|
||||
public update() {
|
||||
public update(forceUpdate?: bool = false) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +114,7 @@ module Phaser {
|
||||
public postUpdate() {
|
||||
}
|
||||
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number, forceRender?: bool = false) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -239,6 +239,20 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of GameObjects it will update each of them so that their canvas/contexts reference this DynamicTexture
|
||||
* @param objects {Array} An array of GameObjects, or objects that inherit from it such as Sprites
|
||||
*/
|
||||
public assignCanvasToGameObjects(objects: GameObject[]) {
|
||||
|
||||
for (var i = 0; i < objects.length; i++)
|
||||
{
|
||||
objects[i].canvas = this.canvas;
|
||||
objects[i].context = this.context;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the whole canvas.
|
||||
*/
|
||||
@@ -248,6 +262,18 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders this DynamicTexture to the Stage at the given x/y coordinates
|
||||
*
|
||||
* @param x {number} The X coordinate to render on the stage to (given in screen coordinates, not world)
|
||||
* @param y {number} The Y coordinate to render on the stage to (given in screen coordinates, not world)
|
||||
*/
|
||||
public render(x?: number = 0, y?: number = 0) {
|
||||
|
||||
this._game.stage.context.drawImage(this.canvas, x, y);
|
||||
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.bounds.width;
|
||||
}
|
||||
|
||||
+3
-3
@@ -661,11 +661,11 @@ module Phaser {
|
||||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param MaxSize {number} Optional, capacity of this group.
|
||||
* @param maxSize {number} Optional, capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
return this.world.createGroup(MaxSize);
|
||||
public createGroup(maxSize?: number = 0): Group {
|
||||
return this.world.createGroup(maxSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+17
-7
@@ -98,7 +98,12 @@ module Phaser {
|
||||
/**
|
||||
* Automatically goes through and calls update on everything you added.
|
||||
*/
|
||||
public update() {
|
||||
public update(forceUpdate?: bool = false) {
|
||||
|
||||
if (this.ignoreGlobalUpdate && forceUpdate == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
@@ -107,10 +112,10 @@ module Phaser {
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.active)
|
||||
if ((basic != null) && basic.exists && basic.active && basic.ignoreGlobalUpdate == false)
|
||||
{
|
||||
basic.preUpdate();
|
||||
basic.update();
|
||||
basic.update(forceUpdate);
|
||||
basic.postUpdate();
|
||||
}
|
||||
}
|
||||
@@ -119,7 +124,12 @@ module Phaser {
|
||||
/**
|
||||
* Automatically goes through and calls render on everything you added.
|
||||
*/
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number, forceRender?: bool = false) {
|
||||
|
||||
if (this.ignoreGlobalRender && forceRender == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
@@ -128,9 +138,9 @@ module Phaser {
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.visible)
|
||||
if ((basic != null) && basic.exists && basic.visible && basic.ignoreGlobalRender == false)
|
||||
{
|
||||
basic.render(camera, cameraOffsetX, cameraOffsetY);
|
||||
basic.render(camera, cameraOffsetX, cameraOffsetY, forceRender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,7 +199,7 @@ module Phaser {
|
||||
* @param {Basic} Object The object you want to add to the group.
|
||||
* @return {Basic} The same <code>Basic</code> object that was passed in.
|
||||
*/
|
||||
public add(Object: Basic) {
|
||||
public add(Object: Basic): any {
|
||||
|
||||
//Don't bother adding an object twice.
|
||||
if (this.members.indexOf(Object) >= 0)
|
||||
|
||||
+9
-2
@@ -32,26 +32,32 @@ module Phaser {
|
||||
* Local private reference to game.
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* Array stors assets keys. So you can get that asset by its unique key.
|
||||
*/
|
||||
private _keys: string[];
|
||||
|
||||
/**
|
||||
* Contains all the assets file infos.
|
||||
*/
|
||||
private _fileList;
|
||||
|
||||
/**
|
||||
* Game initialial assets loading callback.
|
||||
*/
|
||||
private _gameCreateComplete;
|
||||
private _onComplete;
|
||||
private _onFileLoad;
|
||||
|
||||
/**
|
||||
* Indicates assets loading progress. (from 0 to 100)
|
||||
* @type {number}
|
||||
*/
|
||||
private _progressChunk: number;
|
||||
|
||||
private _xhr: XMLHttpRequest;
|
||||
|
||||
/**
|
||||
* Length of assets queue.
|
||||
* @type {number}
|
||||
@@ -63,6 +69,7 @@ module Phaser {
|
||||
* @type {boolean}
|
||||
*/
|
||||
public hasLoaded: bool;
|
||||
|
||||
/**
|
||||
* Loading progress (from 0 to 1)
|
||||
* @type {number}
|
||||
@@ -404,9 +411,9 @@ module Phaser {
|
||||
|
||||
this.progress = Math.round(this.progress + this._progressChunk);
|
||||
|
||||
if (this.progress > 1)
|
||||
if (this.progress > 100)
|
||||
{
|
||||
this.progress = 1;
|
||||
this.progress = 100;
|
||||
}
|
||||
|
||||
if (this._onFileLoad)
|
||||
|
||||
+3
-3
@@ -196,11 +196,11 @@ module Phaser {
|
||||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param MaxSize {number} [optional] capacity of this group.
|
||||
* @param maxSize {number} [optional] capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
return this.game.world.createGroup(MaxSize);
|
||||
public createGroup(maxSize?: number = 0): Group {
|
||||
return this.game.world.createGroup(maxSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -222,11 +222,11 @@ module Phaser {
|
||||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param [MaxSize] {number} capacity of this group.
|
||||
* @param [maxSize] {number} capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
return <Group> this.group.add(new Group(this._game, MaxSize));
|
||||
public createGroup(maxSize?: number = 0): Group {
|
||||
return <Group> this.group.add(new Group(this._game, maxSize));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,14 +17,16 @@ module Phaser {
|
||||
* Creates a new <code>Emitter</code> object at a specific position.
|
||||
* Does NOT automatically generate or attach particles!
|
||||
*
|
||||
* @param X {number} The X position of the emitter.
|
||||
* @param Y {number} The Y position of the emitter.
|
||||
* @param [Size] {number} specifies a maximum capacity for this emitter.
|
||||
* @param x {number} The X position of the emitter.
|
||||
* @param y {number} The Y position of the emitter.
|
||||
* @param [size] {number} Specifies a maximum capacity for this emitter.
|
||||
*/
|
||||
constructor(game: Game, X: number = 0, Y: number = 0, Size: number = 0) {
|
||||
super(game, Size);
|
||||
this.x = X;
|
||||
this.y = Y;
|
||||
constructor(game: Game, x: number = 0, y: number = 0, size: number = 0) {
|
||||
|
||||
super(game, size);
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
this.minParticleSpeed = new MicroPoint(-100, -100);
|
||||
@@ -42,6 +44,7 @@ module Phaser {
|
||||
this._explode = true;
|
||||
this.on = false;
|
||||
this._point = new MicroPoint();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,9 @@ module Phaser {
|
||||
|
||||
super(game);
|
||||
|
||||
this.canvas = game.stage.canvas;
|
||||
this.context = game.stage.context;
|
||||
|
||||
this.bounds = new Rectangle(x, y, width, height);
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
@@ -126,7 +129,6 @@ module Phaser {
|
||||
*/
|
||||
public static ALIGN_BOTTOM_RIGHT: number = 8;
|
||||
|
||||
|
||||
/**
|
||||
* Enum value for outOfBoundsAction. Stop the object when is out of world bounds.
|
||||
* @type {number}
|
||||
@@ -139,12 +141,28 @@ module Phaser {
|
||||
*/
|
||||
public static OUT_OF_BOUNDS_KILL: number = 1;
|
||||
|
||||
/**
|
||||
* A reference to the Canvas this GameObject will render to
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
public canvas: HTMLCanvasElement;
|
||||
|
||||
/**
|
||||
* A reference to the Canvas Context2D this GameObject will render to
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
public context: CanvasRenderingContext2D;
|
||||
|
||||
/**
|
||||
* Position of this object after scrolling.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public _point: MicroPoint;
|
||||
|
||||
/**
|
||||
* An Array of Cameras to which this GameObject won't render
|
||||
* @type {Array}
|
||||
*/
|
||||
public cameraBlacklist: number[];
|
||||
|
||||
/**
|
||||
@@ -352,8 +370,6 @@ module Phaser {
|
||||
*/
|
||||
public preUpdate() {
|
||||
|
||||
// flicker time
|
||||
|
||||
this.last.x = this.bounds.x;
|
||||
this.last.y = this.bounds.y;
|
||||
|
||||
@@ -761,6 +777,18 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the world bounds that this GameObject can exist within based on the size of the current game world.
|
||||
*
|
||||
* @param action {number} The action to take if the object hits the world bounds, either OUT_OF_BOUNDS_KILL or OUT_OF_BOUNDS_STOP
|
||||
*/
|
||||
public setBoundsFromWorld(action?: number = GameObject.OUT_OF_BOUNDS_STOP) {
|
||||
|
||||
this.setBounds(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height);
|
||||
this.outOfBoundsAction = action;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* If you do not wish this object to be visible to a specific camera, pass the camera here.
|
||||
*
|
||||
|
||||
@@ -46,21 +46,25 @@ module Phaser {
|
||||
* Not completely set yet. (the default type)
|
||||
*/
|
||||
public static UNASSIGNED: number = 0;
|
||||
|
||||
/**
|
||||
* Circle.
|
||||
* @type {number}
|
||||
*/
|
||||
public static CIRCLE: number = 1;
|
||||
|
||||
/**
|
||||
* Line.
|
||||
* @type {number}
|
||||
*/
|
||||
public static LINE: number = 2;
|
||||
|
||||
/**
|
||||
* Point.
|
||||
* @type {number}
|
||||
*/
|
||||
public static POINT: number = 3;
|
||||
|
||||
/**
|
||||
* Rectangle.
|
||||
* @type {number}
|
||||
@@ -72,16 +76,19 @@ module Phaser {
|
||||
* @type {Circle}
|
||||
*/
|
||||
public circle: Circle;
|
||||
|
||||
/**
|
||||
* Line shape container. A Line instance.
|
||||
* @type {Line}
|
||||
*/
|
||||
public line: Line;
|
||||
|
||||
/**
|
||||
* Point shape container. A Point instance.
|
||||
* @type {Point}
|
||||
*/
|
||||
public point: Point;
|
||||
|
||||
/**
|
||||
* Rectangle shape container. A Rectangle instance.
|
||||
* @type {Rectangle}
|
||||
@@ -93,6 +100,7 @@ module Phaser {
|
||||
* @type {boolean}
|
||||
*/
|
||||
public renderOutline: bool = true;
|
||||
|
||||
/**
|
||||
* Fill the shape or not. (default is true)
|
||||
* @type {boolean}
|
||||
@@ -104,11 +112,13 @@ module Phaser {
|
||||
* @type {number}
|
||||
*/
|
||||
public lineWidth: number = 1;
|
||||
|
||||
/**
|
||||
* Width of outline. (default is 1)
|
||||
* @type {number}
|
||||
*/
|
||||
public lineColor: string = 'rgb(0,255,0)';
|
||||
|
||||
/**
|
||||
* Width of outline. (default is 1)
|
||||
* @type {number}
|
||||
@@ -322,8 +332,8 @@ module Phaser {
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._dx = cameraOffsetX + (this.bounds.x - camera.worldView.x);
|
||||
@@ -349,9 +359,9 @@ module Phaser {
|
||||
/*
|
||||
if (this.angle !== 0)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2) - this.origin.x, this._dy + (this._dh / 2) - this.origin.y);
|
||||
this._game.stage.context.rotate(this.angle * (Math.PI / 180));
|
||||
this.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2) - this.origin.x, this._dy + (this._dh / 2) - this.origin.y);
|
||||
this.context.rotate(this.angle * (Math.PI / 180));
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
}
|
||||
@@ -365,12 +375,12 @@ module Phaser {
|
||||
this._game.stage.saveCanvasValues();
|
||||
|
||||
// Debug
|
||||
//this._game.stage.context.fillStyle = 'rgba(255,0,0,0.5)';
|
||||
//this._game.stage.context.fillRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
//this.context.fillStyle = 'rgba(255,0,0,0.5)';
|
||||
//this.context.fillRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
|
||||
this._game.stage.context.lineWidth = this.lineWidth;
|
||||
this._game.stage.context.strokeStyle = this.lineColor;
|
||||
this._game.stage.context.fillStyle = this.fillColor;
|
||||
this.context.lineWidth = this.lineWidth;
|
||||
this.context.strokeStyle = this.lineColor;
|
||||
this.context.fillStyle = this.fillColor;
|
||||
|
||||
if (this._game.stage.fillStyle !== this.fillColor)
|
||||
{
|
||||
@@ -379,52 +389,52 @@ module Phaser {
|
||||
// Primitive Renderer
|
||||
if (this.type == GeomSprite.CIRCLE)
|
||||
{
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.arc(this._dx, this._dy, this.circle.radius, 0, Math.PI * 2);
|
||||
this._game.stage.context.stroke();
|
||||
this.context.beginPath();
|
||||
this.context.arc(this._dx, this._dy, this.circle.radius, 0, Math.PI * 2);
|
||||
this.context.stroke();
|
||||
|
||||
if (this.renderFill)
|
||||
{
|
||||
this._game.stage.context.fill();
|
||||
this.context.fill();
|
||||
}
|
||||
|
||||
this._game.stage.context.closePath();
|
||||
this.context.closePath();
|
||||
}
|
||||
else if (this.type == GeomSprite.LINE)
|
||||
{
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.moveTo(this._dx, this._dy);
|
||||
this._game.stage.context.lineTo(this.line.x2, this.line.y2);
|
||||
this._game.stage.context.stroke();
|
||||
this._game.stage.context.closePath();
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(this._dx, this._dy);
|
||||
this.context.lineTo(this.line.x2, this.line.y2);
|
||||
this.context.stroke();
|
||||
this.context.closePath();
|
||||
}
|
||||
else if (this.type == GeomSprite.POINT)
|
||||
{
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, 2, 2);
|
||||
this.context.fillRect(this._dx, this._dy, 2, 2);
|
||||
}
|
||||
else if (this.type == GeomSprite.RECTANGLE)
|
||||
{
|
||||
// We can use the faster fillRect if we don't need the outline
|
||||
if (this.renderOutline == false)
|
||||
{
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
this.context.fillRect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.rect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
this._game.stage.context.stroke();
|
||||
this.context.beginPath();
|
||||
this.context.rect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
this.context.stroke();
|
||||
|
||||
if (this.renderFill)
|
||||
{
|
||||
this._game.stage.context.fill();
|
||||
this.context.fill();
|
||||
}
|
||||
|
||||
this._game.stage.context.closePath();
|
||||
this.context.closePath();
|
||||
}
|
||||
|
||||
// And now the edge points
|
||||
this._game.stage.context.fillStyle = 'rgb(255,255,255)';
|
||||
this.context.fillStyle = 'rgb(255,255,255)';
|
||||
//this.renderPoint(this.rect.topLeft, this._dx, this._dy, 2);
|
||||
//this.renderPoint(this.rect.topCenter, this._dx, this._dy, 2);
|
||||
//this.renderPoint(this.rect.topRight, this._dx, this._dy, 2);
|
||||
@@ -450,13 +460,13 @@ module Phaser {
|
||||
|
||||
if (this.rotation !== 0)
|
||||
{
|
||||
this._game.stage.context.translate(0, 0);
|
||||
this._game.stage.context.restore();
|
||||
this.context.translate(0, 0);
|
||||
this.context.restore();
|
||||
}
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -472,7 +482,7 @@ module Phaser {
|
||||
*/
|
||||
public renderPoint(point, offsetX?: number = 0, offsetY?: number = 0, size?: number = 1) {
|
||||
|
||||
this._game.stage.context.fillRect(offsetX + point.x, offsetY + point.y, size, size);
|
||||
this.context.fillRect(offsetX + point.x, offsetY + point.y, size, size);
|
||||
|
||||
}
|
||||
|
||||
@@ -484,11 +494,11 @@ module Phaser {
|
||||
*/
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
//this._game.stage.context.fillStyle = color;
|
||||
//this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
//this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
//this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
//this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
//this.context.fillStyle = color;
|
||||
//this.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
//this.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
//this.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
//this.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class ScrollRegion{
|
||||
export class ScrollRegion {
|
||||
|
||||
/**
|
||||
* ScrollRegion constructor
|
||||
@@ -54,6 +54,7 @@ module Phaser {
|
||||
* @type {boolean}
|
||||
*/
|
||||
public visible: bool = true;
|
||||
|
||||
/**
|
||||
* Region scrolling speed.
|
||||
* @type {MicroPoint}
|
||||
|
||||
@@ -202,8 +202,8 @@ module Phaser {
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
|
||||
@@ -221,12 +221,12 @@ module Phaser {
|
||||
// Rotation - needs to work from origin point really, but for now from center
|
||||
if (this.angle !== 0 || this.flipped == true)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
this.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
|
||||
if (this.angle !== 0)
|
||||
{
|
||||
this._game.stage.context.rotate(this.angle * (Math.PI / 180));
|
||||
this.context.rotate(this.angle * (Math.PI / 180));
|
||||
}
|
||||
|
||||
this._dx = -(this._dw / 2);
|
||||
@@ -234,7 +234,7 @@ module Phaser {
|
||||
|
||||
if (this.flipped == true)
|
||||
{
|
||||
this._game.stage.context.scale(-1, 1);
|
||||
this.context.scale(-1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,17 +247,17 @@ module Phaser {
|
||||
{
|
||||
if (this._dynamicTexture)
|
||||
{
|
||||
this.regions[i].render(this._game.stage.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh);
|
||||
this.regions[i].render(this.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.regions[i].render(this._game.stage.context, this._texture, this._dx, this._dy, this._dw, this._dh);
|
||||
this.regions[i].render(this.context, this._texture, this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
}
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -232,8 +232,8 @@ module Phaser {
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._sx = 0;
|
||||
@@ -304,12 +304,12 @@ module Phaser {
|
||||
// Rotation - needs to work from origin point really, but for now from center
|
||||
if (this.angle !== 0 || this.rotationOffset !== 0 || this.flipped == true)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
this.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
|
||||
if (this.renderRotation == true && (this.angle !== 0 || this.rotationOffset !== 0))
|
||||
{
|
||||
this._game.stage.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180));
|
||||
this.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180));
|
||||
}
|
||||
|
||||
this._dx = -(this._dw / 2);
|
||||
@@ -317,7 +317,7 @@ module Phaser {
|
||||
|
||||
if (this.flipped == true)
|
||||
{
|
||||
this._game.stage.context.scale(-1, 1);
|
||||
this.context.scale(-1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ module Phaser {
|
||||
{
|
||||
if (this._dynamicTexture)
|
||||
{
|
||||
this._game.stage.context.drawImage(
|
||||
this.context.drawImage(
|
||||
this._texture.canvas, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
@@ -348,7 +348,7 @@ module Phaser {
|
||||
}
|
||||
else
|
||||
{
|
||||
this._game.stage.context.drawImage(
|
||||
this.context.drawImage(
|
||||
this._texture, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
@@ -363,14 +363,14 @@ module Phaser {
|
||||
}
|
||||
else
|
||||
{
|
||||
this._game.stage.context.fillStyle = this.fillColor;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
this.context.fillStyle = this.fillColor;
|
||||
this.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
|
||||
if (this.flipped === true || this.rotation !== 0 || this.rotationOffset !== 0)
|
||||
{
|
||||
//this._game.stage.context.translate(0, 0);
|
||||
this._game.stage.context.restore();
|
||||
//this.context.translate(0, 0);
|
||||
this.context.restore();
|
||||
}
|
||||
|
||||
if (this.renderDebug)
|
||||
@@ -380,7 +380,7 @@ module Phaser {
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -398,24 +398,24 @@ module Phaser {
|
||||
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y);
|
||||
|
||||
this._game.stage.context.fillStyle = this.renderDebugColor;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
this._game.stage.context.fillStyle = this.renderDebugPointColor;
|
||||
this.context.fillStyle = this.renderDebugColor;
|
||||
this.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
this.context.fillStyle = this.renderDebugPointColor;
|
||||
|
||||
var hw = this.bounds.halfWidth * this.scale.x;
|
||||
var hh = this.bounds.halfHeight * this.scale.y;
|
||||
var sw = (this.bounds.width * this.scale.x) - 1;
|
||||
var sh = (this.bounds.height * this.scale.y) - 1;
|
||||
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, 1, 1); // top left
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy, 1, 1); // top center
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy, 1, 1); // top right
|
||||
this._game.stage.context.fillRect(this._dx, this._dy + hh, 1, 1); // left center
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy + hh, 1, 1); // center
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy + hh, 1, 1); // right center
|
||||
this._game.stage.context.fillRect(this._dx, this._dy + sh, 1, 1); // bottom left
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy + sh, 1, 1); // bottom center
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy + sh, 1, 1); // bottom right
|
||||
this.context.fillRect(this._dx, this._dy, 1, 1); // top left
|
||||
this.context.fillRect(this._dx + hw, this._dy, 1, 1); // top center
|
||||
this.context.fillRect(this._dx + sw, this._dy, 1, 1); // top right
|
||||
this.context.fillRect(this._dx, this._dy + hh, 1, 1); // left center
|
||||
this.context.fillRect(this._dx + hw, this._dy + hh, 1, 1); // center
|
||||
this.context.fillRect(this._dx + sw, this._dy + hh, 1, 1); // right center
|
||||
this.context.fillRect(this._dx, this._dy + sh, 1, 1); // bottom left
|
||||
this.context.fillRect(this._dx + hw, this._dy + sh, 1, 1); // bottom center
|
||||
this.context.fillRect(this._dx + sw, this._dy + sh, 1, 1); // bottom right
|
||||
|
||||
}
|
||||
|
||||
@@ -427,11 +427,11 @@ module Phaser {
|
||||
*/
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
this.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
this.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
this.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ module Phaser {
|
||||
this.boundsInTiles = new Rectangle();
|
||||
//this.scrollFactor = new MicroPoint(1, 1);
|
||||
|
||||
this.canvas = game.stage.canvas;
|
||||
this.context = game.stage.context;
|
||||
|
||||
this.mapData = [];
|
||||
this._tempTileBlock = [];
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
@@ -44,11 +47,13 @@ module Phaser {
|
||||
* Local private reference to game.
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* The tilemap that contains this layer.
|
||||
* @type {Tilemap}
|
||||
*/
|
||||
private _parent: Tilemap;
|
||||
|
||||
/**
|
||||
* Tileset of this layer.
|
||||
*/
|
||||
@@ -78,26 +83,43 @@ module Phaser {
|
||||
* @type {string}
|
||||
*/
|
||||
public name: string;
|
||||
|
||||
/**
|
||||
* A reference to the Canvas this GameObject will render to
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
public canvas: HTMLCanvasElement;
|
||||
|
||||
/**
|
||||
* A reference to the Canvas Context2D this GameObject will render to
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
public context: CanvasRenderingContext2D;
|
||||
|
||||
/**
|
||||
* Opacity of this layer.
|
||||
* @type {number}
|
||||
*/
|
||||
public alpha: number = 1;
|
||||
|
||||
/**
|
||||
* Controls whether update() and draw() are automatically called.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public exists: bool = true;
|
||||
|
||||
/**
|
||||
* Controls whether draw() are automatically called.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public visible: bool = true;
|
||||
|
||||
//public scrollFactor: MicroPoint;
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
public orientation: string;
|
||||
|
||||
/**
|
||||
* Properties of this map layer. (normally set by map editors)
|
||||
*/
|
||||
@@ -108,10 +130,12 @@ module Phaser {
|
||||
* @type {number[][]}
|
||||
*/
|
||||
public mapData;
|
||||
|
||||
/**
|
||||
* Format of this map data, available: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON.
|
||||
*/
|
||||
public mapFormat: number;
|
||||
|
||||
/**
|
||||
* It's width and height are in tiles instead of pixels.
|
||||
* @type {Rectangle}
|
||||
@@ -123,6 +147,7 @@ module Phaser {
|
||||
* @type {number}
|
||||
*/
|
||||
public tileWidth: number;
|
||||
|
||||
/**
|
||||
* Height of a single tile.
|
||||
* @type {number}
|
||||
@@ -135,6 +160,7 @@ module Phaser {
|
||||
* @type {number}
|
||||
*/
|
||||
public widthInTiles: number = 0;
|
||||
|
||||
/**
|
||||
* How many tiles in each column.
|
||||
* Read-only variable, do NOT recommend changing after the map is loaded!
|
||||
@@ -147,6 +173,7 @@ module Phaser {
|
||||
* @type {number}
|
||||
*/
|
||||
public widthInPixels: number = 0;
|
||||
|
||||
/**
|
||||
* Read-only variable, do NOT recommend changing after the map is loaded!
|
||||
* @type {number}
|
||||
@@ -158,6 +185,7 @@ module Phaser {
|
||||
* @type {number}
|
||||
*/
|
||||
public tileMargin: number = 0;
|
||||
|
||||
/**
|
||||
* Distance between every 2 neighbor tile in the tileset texture.
|
||||
* @type {number}
|
||||
@@ -502,11 +530,11 @@ module Phaser {
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('TilemapLayer: ' + this.name, x, y);
|
||||
this._game.stage.context.fillText('startX: ' + this._startX + ' endX: ' + this._maxX, x, y + 14);
|
||||
this._game.stage.context.fillText('startY: ' + this._startY + ' endY: ' + this._maxY, x, y + 28);
|
||||
this._game.stage.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42);
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillText('TilemapLayer: ' + this.name, x, y);
|
||||
this.context.fillText('startX: ' + this._startX + ' endX: ' + this._maxX, x, y + 14);
|
||||
this.context.fillText('startY: ' + this._startY + ' endY: ' + this._maxY, x, y + 28);
|
||||
this.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42);
|
||||
|
||||
}
|
||||
|
||||
@@ -585,8 +613,8 @@ module Phaser {
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
for (var row = this._startY; row < this._startY + this._maxY; row++)
|
||||
@@ -597,7 +625,7 @@ module Phaser {
|
||||
{
|
||||
if (this._tileOffsets[this._columnData[tile]])
|
||||
{
|
||||
this._game.stage.context.drawImage(
|
||||
this.context.drawImage(
|
||||
this._texture, // Source Image
|
||||
this._tileOffsets[this._columnData[tile]].x, // Source X (location within the source image)
|
||||
this._tileOffsets[this._columnData[tile]].y, // Source Y
|
||||
@@ -622,13 +650,12 @@ module Phaser {
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ module Phaser {
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onDoubleTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
|
||||
this.currentPointers = 0;
|
||||
@@ -164,17 +163,12 @@ module Phaser {
|
||||
public onUp: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is tapped: pressed and released quickly
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is tapped: pressed and released quickly.
|
||||
* The signal sends 2 parameters. The Pointer that caused it and a boolean depending if the tap was a single tap or a double tap.
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onTap: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is double tapped: pressed and released quickly twice in succession
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onDoubleTap: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is held down
|
||||
* @type {Phaser.Signal}
|
||||
@@ -193,7 +187,7 @@ module Phaser {
|
||||
* @property doubleTapRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public doubleTapRate: number = 250;
|
||||
public doubleTapRate: number = 300;
|
||||
|
||||
/**
|
||||
* The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event
|
||||
@@ -395,7 +389,6 @@ module Phaser {
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onDoubleTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
|
||||
this.currentPointers = 0;
|
||||
|
||||
@@ -401,7 +401,7 @@ module Phaser {
|
||||
*/
|
||||
public stop(event): Pointer {
|
||||
|
||||
console.log('duration', this.duration);
|
||||
this.timeUp = this._game.time.now;
|
||||
|
||||
if (this._game.input.multiInputOverride == Input.MOUSE_OVERRIDES_TOUCH || this._game.input.multiInputOverride == Input.MOUSE_TOUCH_COMBINE || (this._game.input.multiInputOverride == Input.TOUCH_OVERRIDES_MOUSE && this._game.input.currentPointers == 0))
|
||||
{
|
||||
@@ -410,13 +410,16 @@ module Phaser {
|
||||
// Was it a tap?
|
||||
if (this.duration >= 0 && this.duration <= this._game.input.tapRate)
|
||||
{
|
||||
// Yes, let's dispatch the signal
|
||||
this._game.input.onTap.dispatch(this);
|
||||
|
||||
// Was it a double-tap?
|
||||
if (this.timeUp - this.previousTapTime < this._game.input.doubleTapRate)
|
||||
{
|
||||
this._game.input.onDoubleTap.dispatch(this);
|
||||
// Yes, let's dispatch the signal then with the 2nd parameter set to true
|
||||
this._game.input.onTap.dispatch(this, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Wasn't a double-tap, so dispatch a single tap signal
|
||||
this._game.input.onTap.dispatch(this, false);
|
||||
}
|
||||
|
||||
this.previousTapTime = this.timeUp;
|
||||
@@ -426,10 +429,8 @@ module Phaser {
|
||||
|
||||
this.active = false;
|
||||
this.withinGame = false;
|
||||
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
this.timeUp = this._game.time.now;
|
||||
|
||||
if (this.isMouse == false)
|
||||
{
|
||||
|
||||
@@ -63,12 +63,21 @@ V0.9.6
|
||||
* Added Input.onDown, onUp, onTap, onDoubleTap and onHold signals - all fired by the mouse or touch.
|
||||
* Added Input.recordPointerHistory to record the x/y coordinates a Pointer tracks through. Also Input.recordRate and Input.recordLimit for fine control.
|
||||
* Added Input.multiInputOverride which can be MOUSE_OVERRIDES_TOUCH, TOUCH_OVERRIDES_MOUSE or MOUSE_TOUCH_COMBINE.
|
||||
|
||||
* Added GameObject.setBoundsFromWorld to quickly set the bounds of a game object to match those of the current game world.
|
||||
* Added GameObject.canvas and GameObject.context. By default they reference Stage.canvas but can be changed to anything, i.e. a DynamicTexture
|
||||
* The new canvas and context references are applied to Sprite, GeomSprite and TilemapLayer
|
||||
* Added DynamicTexture.assignCanvasToGameObjects() to allow you to redirect GameObject rendering en-mass to a DynamicTexture
|
||||
* Added DynamicTexture.render(x,y) to render the texture to the Stage canvas
|
||||
* Added Basic.ignoreGlobalUpdate - stops the object being updated as part of the main game loop, you'll need to call update on it yourself
|
||||
* Added Basic.ignoreGlobalRender - stops the object being rendered as part of the main game loop, you'll need to call render on it yourself
|
||||
* Added forceUpdate and forceRender parameters to Group.update and Group.render respectively. Combined with ignoreGlobal you can create custom rendering set-ups
|
||||
* Fixed Loader.progress calculation so it now accurate passes a value between 0 and 100% to your loader callback
|
||||
|
||||
* TODO: Check that tween pausing works with the new performance.now
|
||||
* TODO: Game.Time should monitor pause duration
|
||||
* TODO: Investigate bug re: tilemap collision and animation frames
|
||||
* TODO: Update tests that use arrow keys and include touch/mouse support
|
||||
* TODO: GameObject.clipRect
|
||||
|
||||
|
||||
Requirements
|
||||
|
||||
@@ -116,6 +116,10 @@
|
||||
<DependentUpon>shake.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="input\multitouch.ts" />
|
||||
<TypeScriptCompile Include="groups\display order.ts" />
|
||||
<Content Include="groups\display order.js">
|
||||
<DependentUpon>display order.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="input\multitouch.js">
|
||||
<DependentUpon>multitouch.ts</DependentUpon>
|
||||
</Content>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
|
||||
myGame.loader.addImageFile('card', 'assets/sprites/mana_card.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var items;
|
||||
var card;
|
||||
function create() {
|
||||
items = myGame.createGroup();
|
||||
// Items are rendered in the depth order in which they are added to the Group
|
||||
items.add(myGame.createSprite(64, 100, 'atari1'));
|
||||
card = items.add(myGame.createSprite(240, 80, 'card'));
|
||||
items.add(myGame.createSprite(280, 100, 'atari2'));
|
||||
myGame.input.onTap.addOnce(removeCard, this);
|
||||
}
|
||||
function removeCard() {
|
||||
// Now let's kill the card sprite
|
||||
card.kill();
|
||||
myGame.input.onTap.addOnce(replaceCard, this);
|
||||
}
|
||||
function replaceCard() {
|
||||
// And bring it back to life again - I assume it will render in the same place as before?
|
||||
var bob = items.getFirstDead();
|
||||
bob.revive();
|
||||
}
|
||||
function update() {
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,56 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
|
||||
myGame.loader.addImageFile('card', 'assets/sprites/mana_card.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var items: Phaser.Group;
|
||||
var card: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
items = myGame.createGroup();
|
||||
|
||||
// Items are rendered in the depth order in which they are added to the Group
|
||||
|
||||
items.add(myGame.createSprite(64, 100, 'atari1'));
|
||||
card = <Phaser.Sprite> items.add(myGame.createSprite(240, 80, 'card'));
|
||||
items.add(myGame.createSprite(280, 100, 'atari2'));
|
||||
|
||||
myGame.input.onTap.addOnce(removeCard, this);
|
||||
|
||||
}
|
||||
|
||||
function removeCard() {
|
||||
|
||||
// Now let's kill the card sprite
|
||||
card.kill();
|
||||
|
||||
myGame.input.onTap.addOnce(replaceCard, this);
|
||||
|
||||
}
|
||||
|
||||
function replaceCard() {
|
||||
|
||||
// And bring it back to life again - I assume it will render in the same place as before?
|
||||
var bob = items.getFirstDead();
|
||||
|
||||
bob.revive();
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
+16
-19
@@ -14,29 +14,26 @@
|
||||
function create() {
|
||||
balls = myGame.createGroup();
|
||||
myGame.input.onTap.add(tapped, this);
|
||||
myGame.input.onDoubleTap.add(doubleTapped, this);
|
||||
}
|
||||
function doubleTapped(pointer) {
|
||||
var tempBall = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
|
||||
tempBall.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
|
||||
tempBall.velocity.y = 100 + Math.random() * 150;
|
||||
tempBall.elasticity = 0.9;
|
||||
tempBall.scale.setTo(4, 4);
|
||||
balls.add(tempBall);
|
||||
}
|
||||
function tapped(pointer) {
|
||||
var tempBall = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
|
||||
tempBall.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
|
||||
tempBall.velocity.y = 100 + Math.random() * 150;
|
||||
tempBall.elasticity = 0.9;
|
||||
balls.add(tempBall);
|
||||
function tapped(pointer, doubleTap) {
|
||||
if(balls.countDead() > 0) {
|
||||
var tempBall = balls.getFirstDead();
|
||||
tempBall.revive();
|
||||
tempBall.x = pointer.x;
|
||||
tempBall.y = pointer.y;
|
||||
} else {
|
||||
var tempBall = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
|
||||
tempBall.setBoundsFromWorld(Phaser.GameObject.OUT_OF_BOUNDS_KILL);
|
||||
balls.add(tempBall);
|
||||
}
|
||||
tempBall.velocity.y = 150;
|
||||
if(doubleTap) {
|
||||
tempBall.scale.setTo(4, 4);
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
}
|
||||
function render() {
|
||||
myGame.input.renderDebugInfo(16, 16);
|
||||
//myGame.input.pointer1.renderDebug(true);
|
||||
//myGame.input.pointer2.renderDebug(true);
|
||||
//myGame.input.pointer3.renderDebug(true);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
+19
-20
@@ -24,28 +24,31 @@
|
||||
balls = myGame.createGroup();
|
||||
|
||||
myGame.input.onTap.add(tapped, this);
|
||||
myGame.input.onDoubleTap.add(doubleTapped, this);
|
||||
|
||||
}
|
||||
|
||||
function doubleTapped(pointer: Phaser.Pointer) {
|
||||
function tapped(pointer: Phaser.Pointer, doubleTap: bool) {
|
||||
|
||||
var tempBall: Phaser.Sprite = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
|
||||
tempBall.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
|
||||
tempBall.velocity.y = 100 + Math.random() * 150;
|
||||
tempBall.elasticity = 0.9;
|
||||
tempBall.scale.setTo(4, 4);
|
||||
balls.add(tempBall);
|
||||
if (balls.countDead() > 0)
|
||||
{
|
||||
var tempBall: Phaser.Sprite = <Phaser.Sprite> balls.getFirstDead();
|
||||
tempBall.revive();
|
||||
tempBall.x = pointer.x;
|
||||
tempBall.y = pointer.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tempBall: Phaser.Sprite = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
|
||||
tempBall.setBoundsFromWorld(Phaser.GameObject.OUT_OF_BOUNDS_KILL);
|
||||
balls.add(tempBall);
|
||||
}
|
||||
|
||||
}
|
||||
tempBall.velocity.y = 150;
|
||||
|
||||
function tapped(pointer: Phaser.Pointer) {
|
||||
|
||||
var tempBall: Phaser.Sprite = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
|
||||
tempBall.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
|
||||
tempBall.velocity.y = 100 + Math.random() * 150;
|
||||
tempBall.elasticity = 0.9;
|
||||
balls.add(tempBall);
|
||||
if (doubleTap)
|
||||
{
|
||||
tempBall.scale.setTo(4, 4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,10 +59,6 @@
|
||||
|
||||
myGame.input.renderDebugInfo(16, 16);
|
||||
|
||||
//myGame.input.pointer1.renderDebug(true);
|
||||
//myGame.input.pointer2.renderDebug(true);
|
||||
//myGame.input.pointer3.renderDebug(true);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
+174
-126
@@ -23,6 +23,8 @@ var Phaser;
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
this.isGroup = false;
|
||||
this.ignoreGlobalUpdate = false;
|
||||
this.ignoreGlobalRender = false;
|
||||
this.ignoreDrawDebug = false;
|
||||
}
|
||||
Basic.prototype.destroy = /**
|
||||
@@ -41,14 +43,16 @@ var Phaser;
|
||||
* Override this to update your class's position and appearance.
|
||||
* This is where most of your game rules and behavioral code will go.
|
||||
*/
|
||||
function () {
|
||||
function (forceUpdate) {
|
||||
if (typeof forceUpdate === "undefined") { forceUpdate = false; }
|
||||
};
|
||||
Basic.prototype.postUpdate = /**
|
||||
* Post-update is called right after <code>update()</code> on each object in the game loop.
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Basic.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) {
|
||||
Basic.prototype.render = function (camera, cameraOffsetX, cameraOffsetY, forceRender) {
|
||||
if (typeof forceRender === "undefined") { forceRender = false; }
|
||||
};
|
||||
Basic.prototype.kill = /**
|
||||
* Handy for "killing" game objects.
|
||||
@@ -512,6 +516,8 @@ var Phaser;
|
||||
// Input
|
||||
this.inputEnabled = false;
|
||||
this._inputOver = false;
|
||||
this.canvas = game.stage.canvas;
|
||||
this.context = game.stage.context;
|
||||
this.bounds = new Phaser.Rectangle(x, y, width, height);
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
@@ -559,7 +565,6 @@ var Phaser;
|
||||
* Pre-update is called right before update() on each object in the game loop.
|
||||
*/
|
||||
function () {
|
||||
// flicker time
|
||||
this.last.x = this.bounds.x;
|
||||
this.last.y = this.bounds.y;
|
||||
};
|
||||
@@ -869,6 +874,16 @@ var Phaser;
|
||||
function (x, y, width, height) {
|
||||
this.worldBounds = new Phaser.Quad(x, y, width, height);
|
||||
};
|
||||
GameObject.prototype.setBoundsFromWorld = /**
|
||||
* Set the world bounds that this GameObject can exist within based on the size of the current game world.
|
||||
*
|
||||
* @param action {number} The action to take if the object hits the world bounds, either OUT_OF_BOUNDS_KILL or OUT_OF_BOUNDS_STOP
|
||||
*/
|
||||
function (action) {
|
||||
if (typeof action === "undefined") { action = GameObject.OUT_OF_BOUNDS_STOP; }
|
||||
this.setBounds(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height);
|
||||
this.outOfBoundsAction = action;
|
||||
};
|
||||
GameObject.prototype.hideFromCamera = /**
|
||||
* If you do not wish this object to be visible to a specific camera, pass the camera here.
|
||||
*
|
||||
@@ -1620,8 +1635,8 @@ var Phaser;
|
||||
}
|
||||
// Alpha
|
||||
if(this.alpha !== 1) {
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
this._sx = 0;
|
||||
this._sy = 0;
|
||||
@@ -1667,15 +1682,15 @@ var Phaser;
|
||||
}
|
||||
// Rotation - needs to work from origin point really, but for now from center
|
||||
if(this.angle !== 0 || this.rotationOffset !== 0 || this.flipped == true) {
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
this.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
if(this.renderRotation == true && (this.angle !== 0 || this.rotationOffset !== 0)) {
|
||||
this._game.stage.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180));
|
||||
this.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180));
|
||||
}
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
if(this.flipped == true) {
|
||||
this._game.stage.context.scale(-1, 1);
|
||||
this.context.scale(-1, 1);
|
||||
}
|
||||
}
|
||||
this._sx = Math.round(this._sx);
|
||||
@@ -1688,7 +1703,7 @@ var Phaser;
|
||||
this._dh = Math.round(this._dh);
|
||||
if(this._texture != null) {
|
||||
if(this._dynamicTexture) {
|
||||
this._game.stage.context.drawImage(this._texture.canvas, // Source Image
|
||||
this.context.drawImage(this._texture.canvas, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._sw, // Source Width
|
||||
@@ -1699,7 +1714,7 @@ var Phaser;
|
||||
this._dh);
|
||||
// Destination Height (always same as Source Height unless scaled)
|
||||
} else {
|
||||
this._game.stage.context.drawImage(this._texture, // Source Image
|
||||
this.context.drawImage(this._texture, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._sw, // Source Width
|
||||
@@ -1711,18 +1726,18 @@ var Phaser;
|
||||
// Destination Height (always same as Source Height unless scaled)
|
||||
}
|
||||
} else {
|
||||
this._game.stage.context.fillStyle = this.fillColor;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
this.context.fillStyle = this.fillColor;
|
||||
this.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
if(this.flipped === true || this.rotation !== 0 || this.rotationOffset !== 0) {
|
||||
//this._game.stage.context.translate(0, 0);
|
||||
this._game.stage.context.restore();
|
||||
//this.context.translate(0, 0);
|
||||
this.context.restore();
|
||||
}
|
||||
if(this.renderDebug) {
|
||||
this.renderBounds(camera, cameraOffsetX, cameraOffsetY);
|
||||
}
|
||||
if(globalAlpha > -1) {
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -1735,30 +1750,30 @@ var Phaser;
|
||||
function (camera, cameraOffsetX, cameraOffsetY) {
|
||||
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y);
|
||||
this._game.stage.context.fillStyle = this.renderDebugColor;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
this._game.stage.context.fillStyle = this.renderDebugPointColor;
|
||||
this.context.fillStyle = this.renderDebugColor;
|
||||
this.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
this.context.fillStyle = this.renderDebugPointColor;
|
||||
var hw = this.bounds.halfWidth * this.scale.x;
|
||||
var hh = this.bounds.halfHeight * this.scale.y;
|
||||
var sw = (this.bounds.width * this.scale.x) - 1;
|
||||
var sh = (this.bounds.height * this.scale.y) - 1;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, 1, 1)// top left
|
||||
this.context.fillRect(this._dx, this._dy, 1, 1)// top left
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy, 1, 1)// top center
|
||||
this.context.fillRect(this._dx + hw, this._dy, 1, 1)// top center
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy, 1, 1)// top right
|
||||
this.context.fillRect(this._dx + sw, this._dy, 1, 1)// top right
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy + hh, 1, 1)// left center
|
||||
this.context.fillRect(this._dx, this._dy + hh, 1, 1)// left center
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy + hh, 1, 1)// center
|
||||
this.context.fillRect(this._dx + hw, this._dy + hh, 1, 1)// center
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy + hh, 1, 1)// right center
|
||||
this.context.fillRect(this._dx + sw, this._dy + hh, 1, 1)// right center
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy + sh, 1, 1)// bottom left
|
||||
this.context.fillRect(this._dx, this._dy + sh, 1, 1)// bottom left
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy + sh, 1, 1)// bottom center
|
||||
this.context.fillRect(this._dx + hw, this._dy + sh, 1, 1)// bottom center
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy + sh, 1, 1)// bottom right
|
||||
this.context.fillRect(this._dx + sw, this._dy + sh, 1, 1)// bottom right
|
||||
;
|
||||
};
|
||||
Sprite.prototype.renderDebugInfo = /**
|
||||
@@ -1769,11 +1784,11 @@ var Phaser;
|
||||
*/
|
||||
function (x, y, color) {
|
||||
if (typeof color === "undefined") { color = 'rgb(255,255,255)'; }
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
this.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
this.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
this.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
};
|
||||
return Sprite;
|
||||
})(Phaser.GameObject);
|
||||
@@ -5842,12 +5857,33 @@ var Phaser;
|
||||
this.context.putImageData(sourceTexture.getPixels(sourceRect), destPoint.x, destPoint.y);
|
||||
}
|
||||
};
|
||||
DynamicTexture.prototype.assignCanvasToGameObjects = /**
|
||||
* Given an array of GameObjects it will update each of them so that their canvas/contexts reference this DynamicTexture
|
||||
* @param objects {Array} An array of GameObjects, or objects that inherit from it such as Sprites
|
||||
*/
|
||||
function (objects) {
|
||||
for(var i = 0; i < objects.length; i++) {
|
||||
objects[i].canvas = this.canvas;
|
||||
objects[i].context = this.context;
|
||||
}
|
||||
};
|
||||
DynamicTexture.prototype.clear = /**
|
||||
* Clear the whole canvas.
|
||||
*/
|
||||
function () {
|
||||
this.context.clearRect(0, 0, this.bounds.width, this.bounds.height);
|
||||
};
|
||||
DynamicTexture.prototype.render = /**
|
||||
* Renders this DynamicTexture to the Stage at the given x/y coordinates
|
||||
*
|
||||
* @param x {number} The X coordinate to render on the stage to (given in screen coordinates, not world)
|
||||
* @param y {number} The Y coordinate to render on the stage to (given in screen coordinates, not world)
|
||||
*/
|
||||
function (x, y) {
|
||||
if (typeof x === "undefined") { x = 0; }
|
||||
if (typeof y === "undefined") { y = 0; }
|
||||
this._game.stage.context.drawImage(this.canvas, x, y);
|
||||
};
|
||||
Object.defineProperty(DynamicTexture.prototype, "width", {
|
||||
get: function () {
|
||||
return this.bounds.width;
|
||||
@@ -6807,14 +6843,18 @@ var Phaser;
|
||||
Group.prototype.update = /**
|
||||
* Automatically goes through and calls update on everything you added.
|
||||
*/
|
||||
function () {
|
||||
function (forceUpdate) {
|
||||
if (typeof forceUpdate === "undefined") { forceUpdate = false; }
|
||||
if(this.ignoreGlobalUpdate && forceUpdate == false) {
|
||||
return;
|
||||
}
|
||||
var basic;
|
||||
var i = 0;
|
||||
while(i < this.length) {
|
||||
basic = this.members[i++];
|
||||
if((basic != null) && basic.exists && basic.active) {
|
||||
if((basic != null) && basic.exists && basic.active && basic.ignoreGlobalUpdate == false) {
|
||||
basic.preUpdate();
|
||||
basic.update();
|
||||
basic.update(forceUpdate);
|
||||
basic.postUpdate();
|
||||
}
|
||||
}
|
||||
@@ -6822,13 +6862,17 @@ var Phaser;
|
||||
Group.prototype.render = /**
|
||||
* Automatically goes through and calls render on everything you added.
|
||||
*/
|
||||
function (camera, cameraOffsetX, cameraOffsetY) {
|
||||
function (camera, cameraOffsetX, cameraOffsetY, forceRender) {
|
||||
if (typeof forceRender === "undefined") { forceRender = false; }
|
||||
if(this.ignoreGlobalRender && forceRender == false) {
|
||||
return;
|
||||
}
|
||||
var basic;
|
||||
var i = 0;
|
||||
while(i < this.length) {
|
||||
basic = this.members[i++];
|
||||
if((basic != null) && basic.exists && basic.visible) {
|
||||
basic.render(camera, cameraOffsetX, cameraOffsetY);
|
||||
if((basic != null) && basic.exists && basic.visible && basic.ignoreGlobalRender == false) {
|
||||
basic.render(camera, cameraOffsetX, cameraOffsetY, forceRender);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -7508,6 +7552,7 @@ var Phaser;
|
||||
this._onFileLoad = onFileLoadCallback;
|
||||
if(this._keys.length > 0) {
|
||||
this._progressChunk = 100 / this._keys.length;
|
||||
console.log('prog chunk', this._progressChunk);
|
||||
this.loadFile();
|
||||
} else {
|
||||
this.progress = 1;
|
||||
@@ -7647,8 +7692,10 @@ var Phaser;
|
||||
*/
|
||||
function (previousKey, success) {
|
||||
this.progress = Math.round(this.progress + this._progressChunk);
|
||||
if(this.progress > 1) {
|
||||
this.progress = 1;
|
||||
//this.progress = this.progress + this._progressChunk;
|
||||
console.log('progress', this.progress);
|
||||
if(this.progress > 100) {
|
||||
this.progress = 100;
|
||||
}
|
||||
if(this._onFileLoad) {
|
||||
this._onFileLoad.call(this._game.callbackContext, this.progress, previousKey, success);
|
||||
@@ -9889,12 +9936,12 @@ var Phaser;
|
||||
World.prototype.createGroup = /**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param [MaxSize] {number} capacity of this group.
|
||||
* @param [maxSize] {number} capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
function (MaxSize) {
|
||||
if (typeof MaxSize === "undefined") { MaxSize = 0; }
|
||||
return this.group.add(new Phaser.Group(this._game, MaxSize));
|
||||
function (maxSize) {
|
||||
if (typeof maxSize === "undefined") { maxSize = 0; }
|
||||
return this.group.add(new Phaser.Group(this._game, maxSize));
|
||||
};
|
||||
World.prototype.createScrollZone = /**
|
||||
* Create a new ScrollZone object with image key, position and size.
|
||||
@@ -10995,16 +11042,18 @@ var Phaser;
|
||||
* @param {Any} event
|
||||
*/
|
||||
function (event) {
|
||||
console.log('duration', this.duration);
|
||||
this.timeUp = this._game.time.now;
|
||||
if(this._game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this._game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this._game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this._game.input.currentPointers == 0)) {
|
||||
this._game.input.onUp.dispatch(this);
|
||||
// Was it a tap?
|
||||
if(this.duration >= 0 && this.duration <= this._game.input.tapRate) {
|
||||
// Yes, let's dispatch the signal
|
||||
this._game.input.onTap.dispatch(this);
|
||||
// Was it a double-tap?
|
||||
if(this.timeUp - this.previousTapTime < this._game.input.doubleTapRate) {
|
||||
this._game.input.onDoubleTap.dispatch(this);
|
||||
// Yes, let's dispatch the signal then with the 2nd parameter set to true
|
||||
this._game.input.onTap.dispatch(this, true);
|
||||
} else {
|
||||
// Wasn't a double-tap, so dispatch a single tap signal
|
||||
this._game.input.onTap.dispatch(this, false);
|
||||
}
|
||||
this.previousTapTime = this.timeUp;
|
||||
}
|
||||
@@ -11013,7 +11062,6 @@ var Phaser;
|
||||
this.withinGame = false;
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
this.timeUp = this._game.time.now;
|
||||
if(this.isMouse == false) {
|
||||
this._game.input.currentPointers--;
|
||||
}
|
||||
@@ -11308,7 +11356,7 @@ var Phaser;
|
||||
* @property doubleTapRate
|
||||
* @type {Number}
|
||||
**/
|
||||
this.doubleTapRate = 250;
|
||||
this.doubleTapRate = 300;
|
||||
/**
|
||||
* The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event
|
||||
* @property holdRate
|
||||
@@ -11368,7 +11416,6 @@ var Phaser;
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onDoubleTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
this.currentPointers = 0;
|
||||
}
|
||||
@@ -11440,7 +11487,6 @@ var Phaser;
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onDoubleTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
this.currentPointers = 0;
|
||||
};
|
||||
@@ -12210,17 +12256,17 @@ var Phaser;
|
||||
* Creates a new <code>Emitter</code> object at a specific position.
|
||||
* Does NOT automatically generate or attach particles!
|
||||
*
|
||||
* @param X {number} The X position of the emitter.
|
||||
* @param Y {number} The Y position of the emitter.
|
||||
* @param [Size] {number} specifies a maximum capacity for this emitter.
|
||||
* @param x {number} The X position of the emitter.
|
||||
* @param y {number} The Y position of the emitter.
|
||||
* @param [size] {number} Specifies a maximum capacity for this emitter.
|
||||
*/
|
||||
function Emitter(game, X, Y, Size) {
|
||||
if (typeof X === "undefined") { X = 0; }
|
||||
if (typeof Y === "undefined") { Y = 0; }
|
||||
if (typeof Size === "undefined") { Size = 0; }
|
||||
_super.call(this, game, Size);
|
||||
this.x = X;
|
||||
this.y = Y;
|
||||
function Emitter(game, x, y, size) {
|
||||
if (typeof x === "undefined") { x = 0; }
|
||||
if (typeof y === "undefined") { y = 0; }
|
||||
if (typeof size === "undefined") { size = 0; }
|
||||
_super.call(this, game, size);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
this.minParticleSpeed = new Phaser.MicroPoint(-100, -100);
|
||||
@@ -12699,8 +12745,8 @@ var Phaser;
|
||||
}
|
||||
// Alpha
|
||||
if(this.alpha !== 1) {
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
this._dx = cameraOffsetX + (this.bounds.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.y - camera.worldView.y);
|
||||
@@ -12720,9 +12766,9 @@ var Phaser;
|
||||
/*
|
||||
if (this.angle !== 0)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2) - this.origin.x, this._dy + (this._dh / 2) - this.origin.y);
|
||||
this._game.stage.context.rotate(this.angle * (Math.PI / 180));
|
||||
this.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2) - this.origin.x, this._dy + (this._dh / 2) - this.origin.y);
|
||||
this.context.rotate(this.angle * (Math.PI / 180));
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
}
|
||||
@@ -12733,45 +12779,45 @@ var Phaser;
|
||||
this._dh = Math.round(this._dh);
|
||||
this._game.stage.saveCanvasValues();
|
||||
// Debug
|
||||
//this._game.stage.context.fillStyle = 'rgba(255,0,0,0.5)';
|
||||
//this._game.stage.context.fillRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
this._game.stage.context.lineWidth = this.lineWidth;
|
||||
this._game.stage.context.strokeStyle = this.lineColor;
|
||||
this._game.stage.context.fillStyle = this.fillColor;
|
||||
//this.context.fillStyle = 'rgba(255,0,0,0.5)';
|
||||
//this.context.fillRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
this.context.lineWidth = this.lineWidth;
|
||||
this.context.strokeStyle = this.lineColor;
|
||||
this.context.fillStyle = this.fillColor;
|
||||
if(this._game.stage.fillStyle !== this.fillColor) {
|
||||
}
|
||||
// Primitive Renderer
|
||||
if(this.type == GeomSprite.CIRCLE) {
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.arc(this._dx, this._dy, this.circle.radius, 0, Math.PI * 2);
|
||||
this._game.stage.context.stroke();
|
||||
this.context.beginPath();
|
||||
this.context.arc(this._dx, this._dy, this.circle.radius, 0, Math.PI * 2);
|
||||
this.context.stroke();
|
||||
if(this.renderFill) {
|
||||
this._game.stage.context.fill();
|
||||
this.context.fill();
|
||||
}
|
||||
this._game.stage.context.closePath();
|
||||
this.context.closePath();
|
||||
} else if(this.type == GeomSprite.LINE) {
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.moveTo(this._dx, this._dy);
|
||||
this._game.stage.context.lineTo(this.line.x2, this.line.y2);
|
||||
this._game.stage.context.stroke();
|
||||
this._game.stage.context.closePath();
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(this._dx, this._dy);
|
||||
this.context.lineTo(this.line.x2, this.line.y2);
|
||||
this.context.stroke();
|
||||
this.context.closePath();
|
||||
} else if(this.type == GeomSprite.POINT) {
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, 2, 2);
|
||||
this.context.fillRect(this._dx, this._dy, 2, 2);
|
||||
} else if(this.type == GeomSprite.RECTANGLE) {
|
||||
// We can use the faster fillRect if we don't need the outline
|
||||
if(this.renderOutline == false) {
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
this.context.fillRect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
} else {
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.rect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
this._game.stage.context.stroke();
|
||||
this.context.beginPath();
|
||||
this.context.rect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
this.context.stroke();
|
||||
if(this.renderFill) {
|
||||
this._game.stage.context.fill();
|
||||
this.context.fill();
|
||||
}
|
||||
this._game.stage.context.closePath();
|
||||
this.context.closePath();
|
||||
}
|
||||
// And now the edge points
|
||||
this._game.stage.context.fillStyle = 'rgb(255,255,255)';
|
||||
this.context.fillStyle = 'rgb(255,255,255)';
|
||||
//this.renderPoint(this.rect.topLeft, this._dx, this._dy, 2);
|
||||
//this.renderPoint(this.rect.topCenter, this._dx, this._dy, 2);
|
||||
//this.renderPoint(this.rect.topRight, this._dx, this._dy, 2);
|
||||
@@ -12793,11 +12839,11 @@ var Phaser;
|
||||
}
|
||||
this._game.stage.restoreCanvasValues();
|
||||
if(this.rotation !== 0) {
|
||||
this._game.stage.context.translate(0, 0);
|
||||
this._game.stage.context.restore();
|
||||
this.context.translate(0, 0);
|
||||
this.context.restore();
|
||||
}
|
||||
if(globalAlpha > -1) {
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -12812,7 +12858,7 @@ var Phaser;
|
||||
if (typeof offsetX === "undefined") { offsetX = 0; }
|
||||
if (typeof offsetY === "undefined") { offsetY = 0; }
|
||||
if (typeof size === "undefined") { size = 1; }
|
||||
this._game.stage.context.fillRect(offsetX + point.x, offsetY + point.y, size, size);
|
||||
this.context.fillRect(offsetX + point.x, offsetY + point.y, size, size);
|
||||
};
|
||||
GeomSprite.prototype.renderDebugInfo = /**
|
||||
* Render debug infos. (this method does not work now)
|
||||
@@ -12822,11 +12868,11 @@ var Phaser;
|
||||
*/
|
||||
function (x, y, color) {
|
||||
if (typeof color === "undefined") { color = 'rgb(255,255,255)'; }
|
||||
//this._game.stage.context.fillStyle = color;
|
||||
//this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
//this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
//this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
//this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
//this.context.fillStyle = color;
|
||||
//this.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
//this.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
//this.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
//this.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
};
|
||||
GeomSprite.prototype.collide = /**
|
||||
* Gives a basic boolean response to a geometric collision.
|
||||
@@ -13061,6 +13107,8 @@ var Phaser;
|
||||
this.tileHeight = tileHeight;
|
||||
this.boundsInTiles = new Phaser.Rectangle();
|
||||
//this.scrollFactor = new MicroPoint(1, 1);
|
||||
this.canvas = game.stage.canvas;
|
||||
this.context = game.stage.context;
|
||||
this.mapData = [];
|
||||
this._tempTileBlock = [];
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
@@ -13336,11 +13384,11 @@ var Phaser;
|
||||
};
|
||||
TilemapLayer.prototype.renderDebugInfo = function (x, y, color) {
|
||||
if (typeof color === "undefined") { color = 'rgb(255,255,255)'; }
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('TilemapLayer: ' + this.name, x, y);
|
||||
this._game.stage.context.fillText('startX: ' + this._startX + ' endX: ' + this._maxX, x, y + 14);
|
||||
this._game.stage.context.fillText('startY: ' + this._startY + ' endY: ' + this._maxY, x, y + 28);
|
||||
this._game.stage.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42);
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillText('TilemapLayer: ' + this.name, x, y);
|
||||
this.context.fillText('startX: ' + this._startX + ' endX: ' + this._maxX, x, y + 14);
|
||||
this.context.fillText('startY: ' + this._startY + ' endY: ' + this._maxY, x, y + 28);
|
||||
this.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42);
|
||||
};
|
||||
TilemapLayer.prototype.render = /**
|
||||
* Render this layer to a specific camera with offset to camera.
|
||||
@@ -13395,14 +13443,14 @@ var Phaser;
|
||||
*/
|
||||
// Alpha
|
||||
if(this.alpha !== 1) {
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
for(var row = this._startY; row < this._startY + this._maxY; row++) {
|
||||
this._columnData = this.mapData[row];
|
||||
for(var tile = this._startX; tile < this._startX + this._maxX; tile++) {
|
||||
if(this._tileOffsets[this._columnData[tile]]) {
|
||||
this._game.stage.context.drawImage(this._texture, // Source Image
|
||||
this.context.drawImage(this._texture, // Source Image
|
||||
this._tileOffsets[this._columnData[tile]].x, // Source X (location within the source image)
|
||||
this._tileOffsets[this._columnData[tile]].y, // Source Y
|
||||
this.tileWidth, // Source Width
|
||||
@@ -13419,7 +13467,7 @@ var Phaser;
|
||||
this._ty += this.tileHeight;
|
||||
}
|
||||
if(globalAlpha > -1) {
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -14160,8 +14208,8 @@ var Phaser;
|
||||
}
|
||||
// Alpha
|
||||
if(this.alpha !== 1) {
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y);
|
||||
@@ -14174,15 +14222,15 @@ var Phaser;
|
||||
}
|
||||
// Rotation - needs to work from origin point really, but for now from center
|
||||
if(this.angle !== 0 || this.flipped == true) {
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
this.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
if(this.angle !== 0) {
|
||||
this._game.stage.context.rotate(this.angle * (Math.PI / 180));
|
||||
this.context.rotate(this.angle * (Math.PI / 180));
|
||||
}
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
if(this.flipped == true) {
|
||||
this._game.stage.context.scale(-1, 1);
|
||||
this.context.scale(-1, 1);
|
||||
}
|
||||
}
|
||||
this._dx = Math.round(this._dx);
|
||||
@@ -14191,13 +14239,13 @@ var Phaser;
|
||||
this._dh = Math.round(this._dh);
|
||||
for(var i = 0; i < this.regions.length; i++) {
|
||||
if(this._dynamicTexture) {
|
||||
this.regions[i].render(this._game.stage.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh);
|
||||
this.regions[i].render(this.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh);
|
||||
} else {
|
||||
this.regions[i].render(this._game.stage.context, this._texture, this._dx, this._dy, this._dw, this._dh);
|
||||
this.regions[i].render(this.context, this._texture, this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
}
|
||||
if(globalAlpha > -1) {
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -14687,12 +14735,12 @@ var Phaser;
|
||||
Game.prototype.createGroup = /**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param MaxSize {number} Optional, capacity of this group.
|
||||
* @param maxSize {number} Optional, capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
function (MaxSize) {
|
||||
if (typeof MaxSize === "undefined") { MaxSize = 0; }
|
||||
return this.world.createGroup(MaxSize);
|
||||
function (maxSize) {
|
||||
if (typeof maxSize === "undefined") { maxSize = 0; }
|
||||
return this.world.createGroup(maxSize);
|
||||
};
|
||||
Game.prototype.createParticle = /**
|
||||
* Create a new Particle.
|
||||
@@ -15039,12 +15087,12 @@ var Phaser;
|
||||
State.prototype.createGroup = /**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param MaxSize {number} [optional] capacity of this group.
|
||||
* @param maxSize {number} [optional] capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
function (MaxSize) {
|
||||
if (typeof MaxSize === "undefined") { MaxSize = 0; }
|
||||
return this.game.world.createGroup(MaxSize);
|
||||
function (maxSize) {
|
||||
if (typeof maxSize === "undefined") { maxSize = 0; }
|
||||
return this.game.world.createGroup(maxSize);
|
||||
};
|
||||
State.prototype.createParticle = /**
|
||||
* Create a new Particle.
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
map.currentLayer.fillTile(15, 2, 2, 10, 20);
|
||||
}
|
||||
function update() {
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
@@ -48,8 +48,8 @@
|
||||
|
||||
function update() {
|
||||
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
myGame.onRenderCallback = render;
|
||||
}
|
||||
function update() {
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
|
||||
function update() {
|
||||
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
function update() {
|
||||
// Collide everything with the map
|
||||
map.collide();
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 16);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 16);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 16);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 16);
|
||||
if(myGame.input.mousePointer.isDown) {
|
||||
map.putTile(marker.x, marker.y, 32);
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
// Collide everything with the map
|
||||
map.collide();
|
||||
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 16);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 16);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 16);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 16);
|
||||
|
||||
if (myGame.input.mousePointer.isDown)
|
||||
{
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
map.putTile(marker.x, marker.y, 32);
|
||||
}
|
||||
function update() {
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
|
||||
function update() {
|
||||
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
]);
|
||||
}
|
||||
function update() {
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
|
||||
function update() {
|
||||
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
map.currentLayer.replaceTile(30, 31);
|
||||
}
|
||||
function update() {
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
|
||||
function update() {
|
||||
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
map.currentLayer.swapTile(30, 31);
|
||||
}
|
||||
function update() {
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
|
||||
function update() {
|
||||
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32);
|
||||
marker.x = myGame.math.snapToFloor(myGame.input.getWorldX(), 32);
|
||||
marker.y = myGame.math.snapToFloor(myGame.input.getWorldY(), 32);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
|
||||
Vendored
+67
-21
@@ -46,6 +46,14 @@ module Phaser {
|
||||
*/
|
||||
public alive: bool;
|
||||
/**
|
||||
* Setting this to true will prevent the object from being updated during the main game loop (you will have to call update on it yourself)
|
||||
*/
|
||||
public ignoreGlobalUpdate: bool;
|
||||
/**
|
||||
* Setting this to true will prevent the object from being rendered during the main game loop (you will have to call render on it yourself)
|
||||
*/
|
||||
public ignoreGlobalRender: bool;
|
||||
/**
|
||||
* Setting this to true will prevent the object from appearing
|
||||
* when the visual debug mode in the debugger overlay is toggled on.
|
||||
*/
|
||||
@@ -64,12 +72,12 @@ module Phaser {
|
||||
* Override this to update your class's position and appearance.
|
||||
* This is where most of your game rules and behavioral code will go.
|
||||
*/
|
||||
public update(): void;
|
||||
public update(forceUpdate?: bool): void;
|
||||
/**
|
||||
* Post-update is called right after <code>update()</code> on each object in the game loop.
|
||||
*/
|
||||
public postUpdate(): void;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number, forceRender?: bool): void;
|
||||
/**
|
||||
* Handy for "killing" game objects.
|
||||
* Default behavior is to flag them as nonexistent AND dead.
|
||||
@@ -419,10 +427,24 @@ module Phaser {
|
||||
*/
|
||||
static OUT_OF_BOUNDS_KILL: number;
|
||||
/**
|
||||
* A reference to the Canvas this GameObject will render to
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
public canvas: HTMLCanvasElement;
|
||||
/**
|
||||
* A reference to the Canvas Context2D this GameObject will render to
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
public context: CanvasRenderingContext2D;
|
||||
/**
|
||||
* Position of this object after scrolling.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public _point: MicroPoint;
|
||||
/**
|
||||
* An Array of Cameras to which this GameObject won't render
|
||||
* @type {Array}
|
||||
*/
|
||||
public cameraBlacklist: number[];
|
||||
/**
|
||||
* Rectangle container of this object.
|
||||
@@ -722,6 +744,12 @@ module Phaser {
|
||||
*/
|
||||
public setBounds(x: number, y: number, width: number, height: number): void;
|
||||
/**
|
||||
* Set the world bounds that this GameObject can exist within based on the size of the current game world.
|
||||
*
|
||||
* @param action {number} The action to take if the object hits the world bounds, either OUT_OF_BOUNDS_KILL or OUT_OF_BOUNDS_STOP
|
||||
*/
|
||||
public setBoundsFromWorld(action?: number): void;
|
||||
/**
|
||||
* If you do not wish this object to be visible to a specific camera, pass the camera here.
|
||||
*
|
||||
* @param camera {Camera} The specific camera.
|
||||
@@ -3542,9 +3570,21 @@ module Phaser {
|
||||
*/
|
||||
public copyPixels(sourceTexture: DynamicTexture, sourceRect: Rectangle, destPoint: Point): void;
|
||||
/**
|
||||
* Given an array of GameObjects it will update each of them so that their canvas/contexts reference this DynamicTexture
|
||||
* @param objects {Array} An array of GameObjects, or objects that inherit from it such as Sprites
|
||||
*/
|
||||
public assignCanvasToGameObjects(objects: GameObject[]): void;
|
||||
/**
|
||||
* Clear the whole canvas.
|
||||
*/
|
||||
public clear(): void;
|
||||
/**
|
||||
* Renders this DynamicTexture to the Stage at the given x/y coordinates
|
||||
*
|
||||
* @param x {number} The X coordinate to render on the stage to (given in screen coordinates, not world)
|
||||
* @param y {number} The Y coordinate to render on the stage to (given in screen coordinates, not world)
|
||||
*/
|
||||
public render(x?: number, y?: number): void;
|
||||
public width : number;
|
||||
public height : number;
|
||||
/**
|
||||
@@ -4111,11 +4151,11 @@ module Phaser {
|
||||
/**
|
||||
* Automatically goes through and calls update on everything you added.
|
||||
*/
|
||||
public update(): void;
|
||||
public update(forceUpdate?: bool): void;
|
||||
/**
|
||||
* Automatically goes through and calls render on everything you added.
|
||||
*/
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number, forceRender?: bool): void;
|
||||
/**
|
||||
* The maximum capacity of this group. Default is 0, meaning no max capacity, and the group can just grow.
|
||||
*/
|
||||
@@ -4135,7 +4175,7 @@ module Phaser {
|
||||
* @param {Basic} Object The object you want to add to the group.
|
||||
* @return {Basic} The same <code>Basic</code> object that was passed in.
|
||||
*/
|
||||
public add(Object: Basic): Basic;
|
||||
public add(Object: Basic): any;
|
||||
/**
|
||||
* Recycling is designed to help you reuse game objects without always re-allocating or "newing" them.
|
||||
*
|
||||
@@ -5652,10 +5692,10 @@ module Phaser {
|
||||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param [MaxSize] {number} capacity of this group.
|
||||
* @param [maxSize] {number} capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public createGroup(MaxSize?: number): Group;
|
||||
public createGroup(maxSize?: number): Group;
|
||||
/**
|
||||
* Create a new ScrollZone object with image key, position and size.
|
||||
*
|
||||
@@ -6601,16 +6641,12 @@ module Phaser {
|
||||
*/
|
||||
public onUp: Signal;
|
||||
/**
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is tapped: pressed and released quickly
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is tapped: pressed and released quickly.
|
||||
* The signal sends 2 parameters. The Pointer that caused it and a boolean depending if the tap was a single tap or a double tap.
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onTap: Signal;
|
||||
/**
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is double tapped: pressed and released quickly twice in succession
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onDoubleTap: Signal;
|
||||
/**
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is held down
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
@@ -7110,11 +7146,11 @@ module Phaser {
|
||||
* Creates a new <code>Emitter</code> object at a specific position.
|
||||
* Does NOT automatically generate or attach particles!
|
||||
*
|
||||
* @param X {number} The X position of the emitter.
|
||||
* @param Y {number} The Y position of the emitter.
|
||||
* @param [Size] {number} specifies a maximum capacity for this emitter.
|
||||
* @param x {number} The X position of the emitter.
|
||||
* @param y {number} The Y position of the emitter.
|
||||
* @param [size] {number} Specifies a maximum capacity for this emitter.
|
||||
*/
|
||||
constructor(game: Game, X?: number, Y?: number, Size?: number);
|
||||
constructor(game: Game, x?: number, y?: number, size?: number);
|
||||
/**
|
||||
* The X position of the top left corner of the emitter in world space.
|
||||
*/
|
||||
@@ -7559,6 +7595,16 @@ module Phaser {
|
||||
*/
|
||||
public name: string;
|
||||
/**
|
||||
* A reference to the Canvas this GameObject will render to
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
public canvas: HTMLCanvasElement;
|
||||
/**
|
||||
* A reference to the Canvas Context2D this GameObject will render to
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
public context: CanvasRenderingContext2D;
|
||||
/**
|
||||
* Opacity of this layer.
|
||||
* @type {number}
|
||||
*/
|
||||
@@ -8474,10 +8520,10 @@ module Phaser {
|
||||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param MaxSize {number} Optional, capacity of this group.
|
||||
* @param maxSize {number} Optional, capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public createGroup(MaxSize?: number): Group;
|
||||
public createGroup(maxSize?: number): Group;
|
||||
/**
|
||||
* Create a new Particle.
|
||||
*
|
||||
@@ -8749,10 +8795,10 @@ module Phaser {
|
||||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param MaxSize {number} [optional] capacity of this group.
|
||||
* @param maxSize {number} [optional] capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public createGroup(MaxSize?: number): Group;
|
||||
public createGroup(maxSize?: number): Group;
|
||||
/**
|
||||
* Create a new Particle.
|
||||
*
|
||||
|
||||
+174
-126
@@ -23,6 +23,8 @@ var Phaser;
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
this.isGroup = false;
|
||||
this.ignoreGlobalUpdate = false;
|
||||
this.ignoreGlobalRender = false;
|
||||
this.ignoreDrawDebug = false;
|
||||
}
|
||||
Basic.prototype.destroy = /**
|
||||
@@ -41,14 +43,16 @@ var Phaser;
|
||||
* Override this to update your class's position and appearance.
|
||||
* This is where most of your game rules and behavioral code will go.
|
||||
*/
|
||||
function () {
|
||||
function (forceUpdate) {
|
||||
if (typeof forceUpdate === "undefined") { forceUpdate = false; }
|
||||
};
|
||||
Basic.prototype.postUpdate = /**
|
||||
* Post-update is called right after <code>update()</code> on each object in the game loop.
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Basic.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) {
|
||||
Basic.prototype.render = function (camera, cameraOffsetX, cameraOffsetY, forceRender) {
|
||||
if (typeof forceRender === "undefined") { forceRender = false; }
|
||||
};
|
||||
Basic.prototype.kill = /**
|
||||
* Handy for "killing" game objects.
|
||||
@@ -512,6 +516,8 @@ var Phaser;
|
||||
// Input
|
||||
this.inputEnabled = false;
|
||||
this._inputOver = false;
|
||||
this.canvas = game.stage.canvas;
|
||||
this.context = game.stage.context;
|
||||
this.bounds = new Phaser.Rectangle(x, y, width, height);
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
@@ -559,7 +565,6 @@ var Phaser;
|
||||
* Pre-update is called right before update() on each object in the game loop.
|
||||
*/
|
||||
function () {
|
||||
// flicker time
|
||||
this.last.x = this.bounds.x;
|
||||
this.last.y = this.bounds.y;
|
||||
};
|
||||
@@ -869,6 +874,16 @@ var Phaser;
|
||||
function (x, y, width, height) {
|
||||
this.worldBounds = new Phaser.Quad(x, y, width, height);
|
||||
};
|
||||
GameObject.prototype.setBoundsFromWorld = /**
|
||||
* Set the world bounds that this GameObject can exist within based on the size of the current game world.
|
||||
*
|
||||
* @param action {number} The action to take if the object hits the world bounds, either OUT_OF_BOUNDS_KILL or OUT_OF_BOUNDS_STOP
|
||||
*/
|
||||
function (action) {
|
||||
if (typeof action === "undefined") { action = GameObject.OUT_OF_BOUNDS_STOP; }
|
||||
this.setBounds(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height);
|
||||
this.outOfBoundsAction = action;
|
||||
};
|
||||
GameObject.prototype.hideFromCamera = /**
|
||||
* If you do not wish this object to be visible to a specific camera, pass the camera here.
|
||||
*
|
||||
@@ -1620,8 +1635,8 @@ var Phaser;
|
||||
}
|
||||
// Alpha
|
||||
if(this.alpha !== 1) {
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
this._sx = 0;
|
||||
this._sy = 0;
|
||||
@@ -1667,15 +1682,15 @@ var Phaser;
|
||||
}
|
||||
// Rotation - needs to work from origin point really, but for now from center
|
||||
if(this.angle !== 0 || this.rotationOffset !== 0 || this.flipped == true) {
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
this.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
if(this.renderRotation == true && (this.angle !== 0 || this.rotationOffset !== 0)) {
|
||||
this._game.stage.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180));
|
||||
this.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180));
|
||||
}
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
if(this.flipped == true) {
|
||||
this._game.stage.context.scale(-1, 1);
|
||||
this.context.scale(-1, 1);
|
||||
}
|
||||
}
|
||||
this._sx = Math.round(this._sx);
|
||||
@@ -1688,7 +1703,7 @@ var Phaser;
|
||||
this._dh = Math.round(this._dh);
|
||||
if(this._texture != null) {
|
||||
if(this._dynamicTexture) {
|
||||
this._game.stage.context.drawImage(this._texture.canvas, // Source Image
|
||||
this.context.drawImage(this._texture.canvas, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._sw, // Source Width
|
||||
@@ -1699,7 +1714,7 @@ var Phaser;
|
||||
this._dh);
|
||||
// Destination Height (always same as Source Height unless scaled)
|
||||
} else {
|
||||
this._game.stage.context.drawImage(this._texture, // Source Image
|
||||
this.context.drawImage(this._texture, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._sw, // Source Width
|
||||
@@ -1711,18 +1726,18 @@ var Phaser;
|
||||
// Destination Height (always same as Source Height unless scaled)
|
||||
}
|
||||
} else {
|
||||
this._game.stage.context.fillStyle = this.fillColor;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
this.context.fillStyle = this.fillColor;
|
||||
this.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
if(this.flipped === true || this.rotation !== 0 || this.rotationOffset !== 0) {
|
||||
//this._game.stage.context.translate(0, 0);
|
||||
this._game.stage.context.restore();
|
||||
//this.context.translate(0, 0);
|
||||
this.context.restore();
|
||||
}
|
||||
if(this.renderDebug) {
|
||||
this.renderBounds(camera, cameraOffsetX, cameraOffsetY);
|
||||
}
|
||||
if(globalAlpha > -1) {
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -1735,30 +1750,30 @@ var Phaser;
|
||||
function (camera, cameraOffsetX, cameraOffsetY) {
|
||||
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y);
|
||||
this._game.stage.context.fillStyle = this.renderDebugColor;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
this._game.stage.context.fillStyle = this.renderDebugPointColor;
|
||||
this.context.fillStyle = this.renderDebugColor;
|
||||
this.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
this.context.fillStyle = this.renderDebugPointColor;
|
||||
var hw = this.bounds.halfWidth * this.scale.x;
|
||||
var hh = this.bounds.halfHeight * this.scale.y;
|
||||
var sw = (this.bounds.width * this.scale.x) - 1;
|
||||
var sh = (this.bounds.height * this.scale.y) - 1;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, 1, 1)// top left
|
||||
this.context.fillRect(this._dx, this._dy, 1, 1)// top left
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy, 1, 1)// top center
|
||||
this.context.fillRect(this._dx + hw, this._dy, 1, 1)// top center
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy, 1, 1)// top right
|
||||
this.context.fillRect(this._dx + sw, this._dy, 1, 1)// top right
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy + hh, 1, 1)// left center
|
||||
this.context.fillRect(this._dx, this._dy + hh, 1, 1)// left center
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy + hh, 1, 1)// center
|
||||
this.context.fillRect(this._dx + hw, this._dy + hh, 1, 1)// center
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy + hh, 1, 1)// right center
|
||||
this.context.fillRect(this._dx + sw, this._dy + hh, 1, 1)// right center
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy + sh, 1, 1)// bottom left
|
||||
this.context.fillRect(this._dx, this._dy + sh, 1, 1)// bottom left
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy + sh, 1, 1)// bottom center
|
||||
this.context.fillRect(this._dx + hw, this._dy + sh, 1, 1)// bottom center
|
||||
;
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy + sh, 1, 1)// bottom right
|
||||
this.context.fillRect(this._dx + sw, this._dy + sh, 1, 1)// bottom right
|
||||
;
|
||||
};
|
||||
Sprite.prototype.renderDebugInfo = /**
|
||||
@@ -1769,11 +1784,11 @@ var Phaser;
|
||||
*/
|
||||
function (x, y, color) {
|
||||
if (typeof color === "undefined") { color = 'rgb(255,255,255)'; }
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
this.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
this.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
this.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
};
|
||||
return Sprite;
|
||||
})(Phaser.GameObject);
|
||||
@@ -5842,12 +5857,33 @@ var Phaser;
|
||||
this.context.putImageData(sourceTexture.getPixels(sourceRect), destPoint.x, destPoint.y);
|
||||
}
|
||||
};
|
||||
DynamicTexture.prototype.assignCanvasToGameObjects = /**
|
||||
* Given an array of GameObjects it will update each of them so that their canvas/contexts reference this DynamicTexture
|
||||
* @param objects {Array} An array of GameObjects, or objects that inherit from it such as Sprites
|
||||
*/
|
||||
function (objects) {
|
||||
for(var i = 0; i < objects.length; i++) {
|
||||
objects[i].canvas = this.canvas;
|
||||
objects[i].context = this.context;
|
||||
}
|
||||
};
|
||||
DynamicTexture.prototype.clear = /**
|
||||
* Clear the whole canvas.
|
||||
*/
|
||||
function () {
|
||||
this.context.clearRect(0, 0, this.bounds.width, this.bounds.height);
|
||||
};
|
||||
DynamicTexture.prototype.render = /**
|
||||
* Renders this DynamicTexture to the Stage at the given x/y coordinates
|
||||
*
|
||||
* @param x {number} The X coordinate to render on the stage to (given in screen coordinates, not world)
|
||||
* @param y {number} The Y coordinate to render on the stage to (given in screen coordinates, not world)
|
||||
*/
|
||||
function (x, y) {
|
||||
if (typeof x === "undefined") { x = 0; }
|
||||
if (typeof y === "undefined") { y = 0; }
|
||||
this._game.stage.context.drawImage(this.canvas, x, y);
|
||||
};
|
||||
Object.defineProperty(DynamicTexture.prototype, "width", {
|
||||
get: function () {
|
||||
return this.bounds.width;
|
||||
@@ -6807,14 +6843,18 @@ var Phaser;
|
||||
Group.prototype.update = /**
|
||||
* Automatically goes through and calls update on everything you added.
|
||||
*/
|
||||
function () {
|
||||
function (forceUpdate) {
|
||||
if (typeof forceUpdate === "undefined") { forceUpdate = false; }
|
||||
if(this.ignoreGlobalUpdate && forceUpdate == false) {
|
||||
return;
|
||||
}
|
||||
var basic;
|
||||
var i = 0;
|
||||
while(i < this.length) {
|
||||
basic = this.members[i++];
|
||||
if((basic != null) && basic.exists && basic.active) {
|
||||
if((basic != null) && basic.exists && basic.active && basic.ignoreGlobalUpdate == false) {
|
||||
basic.preUpdate();
|
||||
basic.update();
|
||||
basic.update(forceUpdate);
|
||||
basic.postUpdate();
|
||||
}
|
||||
}
|
||||
@@ -6822,13 +6862,17 @@ var Phaser;
|
||||
Group.prototype.render = /**
|
||||
* Automatically goes through and calls render on everything you added.
|
||||
*/
|
||||
function (camera, cameraOffsetX, cameraOffsetY) {
|
||||
function (camera, cameraOffsetX, cameraOffsetY, forceRender) {
|
||||
if (typeof forceRender === "undefined") { forceRender = false; }
|
||||
if(this.ignoreGlobalRender && forceRender == false) {
|
||||
return;
|
||||
}
|
||||
var basic;
|
||||
var i = 0;
|
||||
while(i < this.length) {
|
||||
basic = this.members[i++];
|
||||
if((basic != null) && basic.exists && basic.visible) {
|
||||
basic.render(camera, cameraOffsetX, cameraOffsetY);
|
||||
if((basic != null) && basic.exists && basic.visible && basic.ignoreGlobalRender == false) {
|
||||
basic.render(camera, cameraOffsetX, cameraOffsetY, forceRender);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -7508,6 +7552,7 @@ var Phaser;
|
||||
this._onFileLoad = onFileLoadCallback;
|
||||
if(this._keys.length > 0) {
|
||||
this._progressChunk = 100 / this._keys.length;
|
||||
console.log('prog chunk', this._progressChunk);
|
||||
this.loadFile();
|
||||
} else {
|
||||
this.progress = 1;
|
||||
@@ -7647,8 +7692,10 @@ var Phaser;
|
||||
*/
|
||||
function (previousKey, success) {
|
||||
this.progress = Math.round(this.progress + this._progressChunk);
|
||||
if(this.progress > 1) {
|
||||
this.progress = 1;
|
||||
//this.progress = this.progress + this._progressChunk;
|
||||
console.log('progress', this.progress);
|
||||
if(this.progress > 100) {
|
||||
this.progress = 100;
|
||||
}
|
||||
if(this._onFileLoad) {
|
||||
this._onFileLoad.call(this._game.callbackContext, this.progress, previousKey, success);
|
||||
@@ -9889,12 +9936,12 @@ var Phaser;
|
||||
World.prototype.createGroup = /**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param [MaxSize] {number} capacity of this group.
|
||||
* @param [maxSize] {number} capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
function (MaxSize) {
|
||||
if (typeof MaxSize === "undefined") { MaxSize = 0; }
|
||||
return this.group.add(new Phaser.Group(this._game, MaxSize));
|
||||
function (maxSize) {
|
||||
if (typeof maxSize === "undefined") { maxSize = 0; }
|
||||
return this.group.add(new Phaser.Group(this._game, maxSize));
|
||||
};
|
||||
World.prototype.createScrollZone = /**
|
||||
* Create a new ScrollZone object with image key, position and size.
|
||||
@@ -10995,16 +11042,18 @@ var Phaser;
|
||||
* @param {Any} event
|
||||
*/
|
||||
function (event) {
|
||||
console.log('duration', this.duration);
|
||||
this.timeUp = this._game.time.now;
|
||||
if(this._game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this._game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this._game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this._game.input.currentPointers == 0)) {
|
||||
this._game.input.onUp.dispatch(this);
|
||||
// Was it a tap?
|
||||
if(this.duration >= 0 && this.duration <= this._game.input.tapRate) {
|
||||
// Yes, let's dispatch the signal
|
||||
this._game.input.onTap.dispatch(this);
|
||||
// Was it a double-tap?
|
||||
if(this.timeUp - this.previousTapTime < this._game.input.doubleTapRate) {
|
||||
this._game.input.onDoubleTap.dispatch(this);
|
||||
// Yes, let's dispatch the signal then with the 2nd parameter set to true
|
||||
this._game.input.onTap.dispatch(this, true);
|
||||
} else {
|
||||
// Wasn't a double-tap, so dispatch a single tap signal
|
||||
this._game.input.onTap.dispatch(this, false);
|
||||
}
|
||||
this.previousTapTime = this.timeUp;
|
||||
}
|
||||
@@ -11013,7 +11062,6 @@ var Phaser;
|
||||
this.withinGame = false;
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
this.timeUp = this._game.time.now;
|
||||
if(this.isMouse == false) {
|
||||
this._game.input.currentPointers--;
|
||||
}
|
||||
@@ -11308,7 +11356,7 @@ var Phaser;
|
||||
* @property doubleTapRate
|
||||
* @type {Number}
|
||||
**/
|
||||
this.doubleTapRate = 250;
|
||||
this.doubleTapRate = 300;
|
||||
/**
|
||||
* The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event
|
||||
* @property holdRate
|
||||
@@ -11368,7 +11416,6 @@ var Phaser;
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onDoubleTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
this.currentPointers = 0;
|
||||
}
|
||||
@@ -11440,7 +11487,6 @@ var Phaser;
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onDoubleTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
this.currentPointers = 0;
|
||||
};
|
||||
@@ -12210,17 +12256,17 @@ var Phaser;
|
||||
* Creates a new <code>Emitter</code> object at a specific position.
|
||||
* Does NOT automatically generate or attach particles!
|
||||
*
|
||||
* @param X {number} The X position of the emitter.
|
||||
* @param Y {number} The Y position of the emitter.
|
||||
* @param [Size] {number} specifies a maximum capacity for this emitter.
|
||||
* @param x {number} The X position of the emitter.
|
||||
* @param y {number} The Y position of the emitter.
|
||||
* @param [size] {number} Specifies a maximum capacity for this emitter.
|
||||
*/
|
||||
function Emitter(game, X, Y, Size) {
|
||||
if (typeof X === "undefined") { X = 0; }
|
||||
if (typeof Y === "undefined") { Y = 0; }
|
||||
if (typeof Size === "undefined") { Size = 0; }
|
||||
_super.call(this, game, Size);
|
||||
this.x = X;
|
||||
this.y = Y;
|
||||
function Emitter(game, x, y, size) {
|
||||
if (typeof x === "undefined") { x = 0; }
|
||||
if (typeof y === "undefined") { y = 0; }
|
||||
if (typeof size === "undefined") { size = 0; }
|
||||
_super.call(this, game, size);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
this.minParticleSpeed = new Phaser.MicroPoint(-100, -100);
|
||||
@@ -12699,8 +12745,8 @@ var Phaser;
|
||||
}
|
||||
// Alpha
|
||||
if(this.alpha !== 1) {
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
this._dx = cameraOffsetX + (this.bounds.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.y - camera.worldView.y);
|
||||
@@ -12720,9 +12766,9 @@ var Phaser;
|
||||
/*
|
||||
if (this.angle !== 0)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2) - this.origin.x, this._dy + (this._dh / 2) - this.origin.y);
|
||||
this._game.stage.context.rotate(this.angle * (Math.PI / 180));
|
||||
this.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2) - this.origin.x, this._dy + (this._dh / 2) - this.origin.y);
|
||||
this.context.rotate(this.angle * (Math.PI / 180));
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
}
|
||||
@@ -12733,45 +12779,45 @@ var Phaser;
|
||||
this._dh = Math.round(this._dh);
|
||||
this._game.stage.saveCanvasValues();
|
||||
// Debug
|
||||
//this._game.stage.context.fillStyle = 'rgba(255,0,0,0.5)';
|
||||
//this._game.stage.context.fillRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
this._game.stage.context.lineWidth = this.lineWidth;
|
||||
this._game.stage.context.strokeStyle = this.lineColor;
|
||||
this._game.stage.context.fillStyle = this.fillColor;
|
||||
//this.context.fillStyle = 'rgba(255,0,0,0.5)';
|
||||
//this.context.fillRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
this.context.lineWidth = this.lineWidth;
|
||||
this.context.strokeStyle = this.lineColor;
|
||||
this.context.fillStyle = this.fillColor;
|
||||
if(this._game.stage.fillStyle !== this.fillColor) {
|
||||
}
|
||||
// Primitive Renderer
|
||||
if(this.type == GeomSprite.CIRCLE) {
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.arc(this._dx, this._dy, this.circle.radius, 0, Math.PI * 2);
|
||||
this._game.stage.context.stroke();
|
||||
this.context.beginPath();
|
||||
this.context.arc(this._dx, this._dy, this.circle.radius, 0, Math.PI * 2);
|
||||
this.context.stroke();
|
||||
if(this.renderFill) {
|
||||
this._game.stage.context.fill();
|
||||
this.context.fill();
|
||||
}
|
||||
this._game.stage.context.closePath();
|
||||
this.context.closePath();
|
||||
} else if(this.type == GeomSprite.LINE) {
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.moveTo(this._dx, this._dy);
|
||||
this._game.stage.context.lineTo(this.line.x2, this.line.y2);
|
||||
this._game.stage.context.stroke();
|
||||
this._game.stage.context.closePath();
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(this._dx, this._dy);
|
||||
this.context.lineTo(this.line.x2, this.line.y2);
|
||||
this.context.stroke();
|
||||
this.context.closePath();
|
||||
} else if(this.type == GeomSprite.POINT) {
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, 2, 2);
|
||||
this.context.fillRect(this._dx, this._dy, 2, 2);
|
||||
} else if(this.type == GeomSprite.RECTANGLE) {
|
||||
// We can use the faster fillRect if we don't need the outline
|
||||
if(this.renderOutline == false) {
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
this.context.fillRect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
} else {
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.rect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
this._game.stage.context.stroke();
|
||||
this.context.beginPath();
|
||||
this.context.rect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
this.context.stroke();
|
||||
if(this.renderFill) {
|
||||
this._game.stage.context.fill();
|
||||
this.context.fill();
|
||||
}
|
||||
this._game.stage.context.closePath();
|
||||
this.context.closePath();
|
||||
}
|
||||
// And now the edge points
|
||||
this._game.stage.context.fillStyle = 'rgb(255,255,255)';
|
||||
this.context.fillStyle = 'rgb(255,255,255)';
|
||||
//this.renderPoint(this.rect.topLeft, this._dx, this._dy, 2);
|
||||
//this.renderPoint(this.rect.topCenter, this._dx, this._dy, 2);
|
||||
//this.renderPoint(this.rect.topRight, this._dx, this._dy, 2);
|
||||
@@ -12793,11 +12839,11 @@ var Phaser;
|
||||
}
|
||||
this._game.stage.restoreCanvasValues();
|
||||
if(this.rotation !== 0) {
|
||||
this._game.stage.context.translate(0, 0);
|
||||
this._game.stage.context.restore();
|
||||
this.context.translate(0, 0);
|
||||
this.context.restore();
|
||||
}
|
||||
if(globalAlpha > -1) {
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -12812,7 +12858,7 @@ var Phaser;
|
||||
if (typeof offsetX === "undefined") { offsetX = 0; }
|
||||
if (typeof offsetY === "undefined") { offsetY = 0; }
|
||||
if (typeof size === "undefined") { size = 1; }
|
||||
this._game.stage.context.fillRect(offsetX + point.x, offsetY + point.y, size, size);
|
||||
this.context.fillRect(offsetX + point.x, offsetY + point.y, size, size);
|
||||
};
|
||||
GeomSprite.prototype.renderDebugInfo = /**
|
||||
* Render debug infos. (this method does not work now)
|
||||
@@ -12822,11 +12868,11 @@ var Phaser;
|
||||
*/
|
||||
function (x, y, color) {
|
||||
if (typeof color === "undefined") { color = 'rgb(255,255,255)'; }
|
||||
//this._game.stage.context.fillStyle = color;
|
||||
//this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
//this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
//this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
//this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
//this.context.fillStyle = color;
|
||||
//this.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
//this.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
//this.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
//this.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
};
|
||||
GeomSprite.prototype.collide = /**
|
||||
* Gives a basic boolean response to a geometric collision.
|
||||
@@ -13061,6 +13107,8 @@ var Phaser;
|
||||
this.tileHeight = tileHeight;
|
||||
this.boundsInTiles = new Phaser.Rectangle();
|
||||
//this.scrollFactor = new MicroPoint(1, 1);
|
||||
this.canvas = game.stage.canvas;
|
||||
this.context = game.stage.context;
|
||||
this.mapData = [];
|
||||
this._tempTileBlock = [];
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
@@ -13336,11 +13384,11 @@ var Phaser;
|
||||
};
|
||||
TilemapLayer.prototype.renderDebugInfo = function (x, y, color) {
|
||||
if (typeof color === "undefined") { color = 'rgb(255,255,255)'; }
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('TilemapLayer: ' + this.name, x, y);
|
||||
this._game.stage.context.fillText('startX: ' + this._startX + ' endX: ' + this._maxX, x, y + 14);
|
||||
this._game.stage.context.fillText('startY: ' + this._startY + ' endY: ' + this._maxY, x, y + 28);
|
||||
this._game.stage.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42);
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillText('TilemapLayer: ' + this.name, x, y);
|
||||
this.context.fillText('startX: ' + this._startX + ' endX: ' + this._maxX, x, y + 14);
|
||||
this.context.fillText('startY: ' + this._startY + ' endY: ' + this._maxY, x, y + 28);
|
||||
this.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42);
|
||||
};
|
||||
TilemapLayer.prototype.render = /**
|
||||
* Render this layer to a specific camera with offset to camera.
|
||||
@@ -13395,14 +13443,14 @@ var Phaser;
|
||||
*/
|
||||
// Alpha
|
||||
if(this.alpha !== 1) {
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
for(var row = this._startY; row < this._startY + this._maxY; row++) {
|
||||
this._columnData = this.mapData[row];
|
||||
for(var tile = this._startX; tile < this._startX + this._maxX; tile++) {
|
||||
if(this._tileOffsets[this._columnData[tile]]) {
|
||||
this._game.stage.context.drawImage(this._texture, // Source Image
|
||||
this.context.drawImage(this._texture, // Source Image
|
||||
this._tileOffsets[this._columnData[tile]].x, // Source X (location within the source image)
|
||||
this._tileOffsets[this._columnData[tile]].y, // Source Y
|
||||
this.tileWidth, // Source Width
|
||||
@@ -13419,7 +13467,7 @@ var Phaser;
|
||||
this._ty += this.tileHeight;
|
||||
}
|
||||
if(globalAlpha > -1) {
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -14160,8 +14208,8 @@ var Phaser;
|
||||
}
|
||||
// Alpha
|
||||
if(this.alpha !== 1) {
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y);
|
||||
@@ -14174,15 +14222,15 @@ var Phaser;
|
||||
}
|
||||
// Rotation - needs to work from origin point really, but for now from center
|
||||
if(this.angle !== 0 || this.flipped == true) {
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
this.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
if(this.angle !== 0) {
|
||||
this._game.stage.context.rotate(this.angle * (Math.PI / 180));
|
||||
this.context.rotate(this.angle * (Math.PI / 180));
|
||||
}
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
if(this.flipped == true) {
|
||||
this._game.stage.context.scale(-1, 1);
|
||||
this.context.scale(-1, 1);
|
||||
}
|
||||
}
|
||||
this._dx = Math.round(this._dx);
|
||||
@@ -14191,13 +14239,13 @@ var Phaser;
|
||||
this._dh = Math.round(this._dh);
|
||||
for(var i = 0; i < this.regions.length; i++) {
|
||||
if(this._dynamicTexture) {
|
||||
this.regions[i].render(this._game.stage.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh);
|
||||
this.regions[i].render(this.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh);
|
||||
} else {
|
||||
this.regions[i].render(this._game.stage.context, this._texture, this._dx, this._dy, this._dw, this._dh);
|
||||
this.regions[i].render(this.context, this._texture, this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
}
|
||||
if(globalAlpha > -1) {
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -14687,12 +14735,12 @@ var Phaser;
|
||||
Game.prototype.createGroup = /**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param MaxSize {number} Optional, capacity of this group.
|
||||
* @param maxSize {number} Optional, capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
function (MaxSize) {
|
||||
if (typeof MaxSize === "undefined") { MaxSize = 0; }
|
||||
return this.world.createGroup(MaxSize);
|
||||
function (maxSize) {
|
||||
if (typeof maxSize === "undefined") { maxSize = 0; }
|
||||
return this.world.createGroup(maxSize);
|
||||
};
|
||||
Game.prototype.createParticle = /**
|
||||
* Create a new Particle.
|
||||
@@ -15039,12 +15087,12 @@ var Phaser;
|
||||
State.prototype.createGroup = /**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param MaxSize {number} [optional] capacity of this group.
|
||||
* @param maxSize {number} [optional] capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
function (MaxSize) {
|
||||
if (typeof MaxSize === "undefined") { MaxSize = 0; }
|
||||
return this.game.world.createGroup(MaxSize);
|
||||
function (maxSize) {
|
||||
if (typeof maxSize === "undefined") { maxSize = 0; }
|
||||
return this.game.world.createGroup(maxSize);
|
||||
};
|
||||
State.prototype.createParticle = /**
|
||||
* Create a new Particle.
|
||||
|
||||
Reference in New Issue
Block a user