mirror of
https://github.com/wassname/phaser.git
synced 2026-07-08 00:10:32 +08:00
More refactoring for 1.0.0
This commit is contained in:
Vendored
-28
@@ -1,28 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="gameobjects/Sprite.d.ts" />
|
||||
/// <reference path="system/animation/Animation.d.ts" />
|
||||
/// <reference path="system/animation/AnimationLoader.d.ts" />
|
||||
/// <reference path="system/animation/Frame.d.ts" />
|
||||
/// <reference path="system/animation/FrameData.d.ts" />
|
||||
module Phaser {
|
||||
class AnimationManager {
|
||||
constructor(game: Game, parent: Sprite);
|
||||
private _game;
|
||||
private _parent;
|
||||
private _anims;
|
||||
private _frameIndex;
|
||||
private _frameData;
|
||||
public currentAnim: Animation;
|
||||
public currentFrame: Frame;
|
||||
public loadFrameData(frameData: FrameData): void;
|
||||
public add(name: string, frames?: any[], frameRate?: number, loop?: bool, useNumericIndex?: bool): void;
|
||||
private validateFrames(frames, useNumericIndex);
|
||||
public play(name: string, frameRate?: number, loop?: bool): void;
|
||||
public stop(name: string): void;
|
||||
public update(): void;
|
||||
public frameData : FrameData;
|
||||
public frameTotal : number;
|
||||
public frame : number;
|
||||
public frameName : string;
|
||||
}
|
||||
}
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class Basic {
|
||||
constructor(game: Game);
|
||||
public _game: Game;
|
||||
public name: string;
|
||||
public ID: number;
|
||||
public isGroup: bool;
|
||||
public exists: bool;
|
||||
public active: bool;
|
||||
public visible: bool;
|
||||
public alive: bool;
|
||||
public ignoreDrawDebug: bool;
|
||||
public destroy(): void;
|
||||
public preUpdate(): void;
|
||||
public update(): void;
|
||||
public postUpdate(): void;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
|
||||
public kill(): void;
|
||||
public revive(): void;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
-150
@@ -1,150 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Basic
|
||||
*
|
||||
* A useful "generic" object on which all GameObjects and Groups are based.
|
||||
* It has no size, position or graphical data.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Basic {
|
||||
|
||||
/**
|
||||
* Instantiate the basic object.
|
||||
*/
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
this.ID = -1;
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
this.isGroup = false;
|
||||
this.ignoreGlobalUpdate = false;
|
||||
this.ignoreGlobalRender = false;
|
||||
this.ignoreDrawDebug = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object
|
||||
*/
|
||||
public _game: Game;
|
||||
|
||||
/**
|
||||
* Allows you to give this object a name. Useful for debugging, but not actually used internally.
|
||||
*/
|
||||
public name: string = '';
|
||||
|
||||
/**
|
||||
* IDs seem like they could be pretty useful, huh?
|
||||
* They're not actually used for anything yet though.
|
||||
*/
|
||||
public ID: number;
|
||||
|
||||
/**
|
||||
* A boolean to store if this object is a Group or not.
|
||||
* Saves us an expensive typeof check inside of core loops.
|
||||
*/
|
||||
public isGroup: bool;
|
||||
|
||||
/**
|
||||
* Controls whether <code>update()</code> and <code>draw()</code> are automatically called by State/Group.
|
||||
*/
|
||||
public exists: bool;
|
||||
|
||||
/**
|
||||
* Controls whether <code>update()</code> is automatically called by State/Group.
|
||||
*/
|
||||
public active: bool;
|
||||
|
||||
/**
|
||||
* Controls whether <code>draw()</code> is automatically called by State/Group.
|
||||
*/
|
||||
public visible: bool;
|
||||
|
||||
/**
|
||||
* Useful state for many game objects - "dead" (!alive) vs alive.
|
||||
* <code>kill()</code> and <code>revive()</code> both flip this switch (along with exists, but you can override that).
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public ignoreDrawDebug: bool;
|
||||
|
||||
/**
|
||||
* Override this to null out iables or manually call
|
||||
* <code>destroy()</code> on class members if necessary.
|
||||
* Don't forget to call <code>super.destroy()</code>!
|
||||
*/
|
||||
public destroy() { }
|
||||
|
||||
/**
|
||||
* Pre-update is called right before <code>update()</code> on each object in the game loop.
|
||||
*/
|
||||
public preUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(forceUpdate?: bool = false) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-update is called right after <code>update()</code> on each object in the game loop.
|
||||
*/
|
||||
public postUpdate() {
|
||||
}
|
||||
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number, forceRender?: bool = false) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for "killing" game objects.
|
||||
* Default behavior is to flag them as nonexistent AND dead.
|
||||
* However, if you want the "corpse" to remain in the game,
|
||||
* like to animate an effect or whatever, you should override this,
|
||||
* setting only alive to false, and leaving exists true.
|
||||
*/
|
||||
public kill() {
|
||||
this.alive = false;
|
||||
this.exists = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for bringing game objects "back to life". Just sets alive and exists back to true.
|
||||
* In practice, this is most often called by <code>Object.reset()</code>.
|
||||
*/
|
||||
public revive() {
|
||||
this.alive = true;
|
||||
this.exists = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert object to readable string name. Useful for debugging, save games, etc.
|
||||
*/
|
||||
public toString(): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-26
@@ -1,26 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class Cache {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _canvases;
|
||||
private _images;
|
||||
private _sounds;
|
||||
private _text;
|
||||
public addCanvas(key: string, canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void;
|
||||
public addSpriteSheet(key: string, url: string, data, frameWidth: number, frameHeight: number, frameMax: number): void;
|
||||
public addTextureAtlas(key: string, url: string, data, jsonData): void;
|
||||
public addImage(key: string, url: string, data): void;
|
||||
public addSound(key: string, url: string, data): void;
|
||||
public decodedSound(key: string, data): void;
|
||||
public addText(key: string, url: string, data): void;
|
||||
public getCanvas(key: string);
|
||||
public getImage(key: string);
|
||||
public getFrameData(key: string): FrameData;
|
||||
public getSound(key: string);
|
||||
public isSoundDecoded(key: string): bool;
|
||||
public isSpriteSheet(key: string): bool;
|
||||
public getText(key: string);
|
||||
public destroy(): void;
|
||||
}
|
||||
}
|
||||
Vendored
-17
@@ -1,17 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="system/Camera.d.ts" />
|
||||
module Phaser {
|
||||
class CameraManager {
|
||||
constructor(game: Game, x: number, y: number, width: number, height: number);
|
||||
private _game;
|
||||
private _cameras;
|
||||
private _cameraInstance;
|
||||
public current: Camera;
|
||||
public getAll(): Camera[];
|
||||
public update(): void;
|
||||
public render(): void;
|
||||
public addCamera(x: number, y: number, width: number, height: number): Camera;
|
||||
public removeCamera(id: number): bool;
|
||||
public destroy(): void;
|
||||
}
|
||||
}
|
||||
Vendored
-53
@@ -1,53 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="geom/Point.d.ts" />
|
||||
/// <reference path="geom/Rectangle.d.ts" />
|
||||
/// <reference path="geom/Quad.d.ts" />
|
||||
/// <reference path="geom/Circle.d.ts" />
|
||||
/// <reference path="geom/Line.d.ts" />
|
||||
/// <reference path="geom/IntersectResult.d.ts" />
|
||||
/// <reference path="system/QuadTree.d.ts" />
|
||||
module Phaser {
|
||||
class Collision {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
static LEFT: number;
|
||||
static RIGHT: number;
|
||||
static UP: number;
|
||||
static DOWN: number;
|
||||
static NONE: number;
|
||||
static CEILING: number;
|
||||
static FLOOR: number;
|
||||
static WALL: number;
|
||||
static ANY: number;
|
||||
static OVERLAP_BIAS: number;
|
||||
static TILE_OVERLAP: bool;
|
||||
static _tempBounds: Quad;
|
||||
static lineToLine(line1: Line, line2: Line, output?: IntersectResult): IntersectResult;
|
||||
static lineToLineSegment(line: Line, seg: Line, output?: IntersectResult): IntersectResult;
|
||||
static lineToRawSegment(line: Line, x1: number, y1: number, x2: number, y2: number, output?: IntersectResult): IntersectResult;
|
||||
static lineToRay(line1: Line, ray: Line, output?: IntersectResult): IntersectResult;
|
||||
static lineToCircle(line: Line, circle: Circle, output?: IntersectResult): IntersectResult;
|
||||
static lineToRectangle(line: Line, rect: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static lineSegmentToLineSegment(line1: Line, line2: Line, output?: IntersectResult): IntersectResult;
|
||||
static lineSegmentToRay(line: Line, ray: Line, output?: IntersectResult): IntersectResult;
|
||||
static lineSegmentToCircle(seg: Line, circle: Circle, output?: IntersectResult): IntersectResult;
|
||||
static lineSegmentToRectangle(seg: Line, rect: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static rayToRectangle(ray: Line, rect: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static rayToLineSegment(rayX1, rayY1, rayX2, rayY2, lineX1, lineY1, lineX2, lineY2, output?: IntersectResult): IntersectResult;
|
||||
static pointToRectangle(point, rect: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static rectangleToRectangle(rect1: Rectangle, rect2: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static rectangleToCircle(rect: Rectangle, circle: Circle, output?: IntersectResult): IntersectResult;
|
||||
static circleToCircle(circle1: Circle, circle2: Circle, output?: IntersectResult): IntersectResult;
|
||||
static circleToRectangle(circle: Circle, rect: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static circleContainsPoint(circle: Circle, point, output?: IntersectResult): IntersectResult;
|
||||
public overlap(object1?: Basic, object2?: Basic, notifyCallback?, processCallback?): bool;
|
||||
static separate(object1, object2): bool;
|
||||
static separateTile(object: GameObject, x: number, y: number, width: number, height: number, mass: number, collideLeft: bool, collideRight: bool, collideUp: bool, collideDown: bool): bool;
|
||||
static separateTileX(object: GameObject, x: number, y: number, width: number, height: number, mass: number, collideLeft: bool, collideRight: bool): bool;
|
||||
static separateTileY(object: GameObject, x: number, y: number, width: number, height: number, mass: number, collideUp: bool, collideDown: bool): bool;
|
||||
static separateX(object1, object2): bool;
|
||||
static separateY(object1, object2): bool;
|
||||
static distance(x1: number, y1: number, x2: number, y2: number): number;
|
||||
static distanceSquared(x1: number, y1: number, x2: number, y2: number): number;
|
||||
}
|
||||
}
|
||||
+19
-19
@@ -1,13 +1,12 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="geom/Point.ts" />
|
||||
/// <reference path="geom/Rectangle.ts" />
|
||||
/// <reference path="geom/Quad.ts" />
|
||||
/// <reference path="geom/Circle.ts" />
|
||||
/// <reference path="core/Point.ts" />
|
||||
/// <reference path="core/Rectangle.ts" />
|
||||
/// <reference path="core/Circle.ts" />
|
||||
/// <reference path="geom/Line.ts" />
|
||||
/// <reference path="geom/IntersectResult.ts" />
|
||||
/// <reference path="geom/Response.ts" />
|
||||
/// <reference path="geom/Vector2.ts" />
|
||||
/// <reference path="system/QuadTree.ts" />
|
||||
/// <reference path="core/Vec2.ts" />
|
||||
/// <reference path="math/QuadTree.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Collision
|
||||
@@ -31,7 +30,7 @@ module Phaser {
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
Collision.T_VECTORS.push(new Vector2);
|
||||
Collision.T_VECTORS.push(new Vec2);
|
||||
}
|
||||
|
||||
Collision.T_ARRAYS = [];
|
||||
@@ -115,10 +114,10 @@ module Phaser {
|
||||
public static TILE_OVERLAP: bool = false;
|
||||
|
||||
/**
|
||||
* A temporary Quad used in the separation process to help avoid gc spikes
|
||||
* @type {Quad}
|
||||
* A temporary Rectangle used in the separation process to help avoid gc spikes
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public static _tempBounds: Quad;
|
||||
public static _tempBounds: Rectangle;
|
||||
|
||||
/**
|
||||
* Checks for Line to Line intersection and returns an IntersectResult object containing the results of the intersection.
|
||||
@@ -498,7 +497,7 @@ module Phaser {
|
||||
|
||||
/**
|
||||
* Determines whether the specified point is contained within the rectangular region defined by the Rectangle object and returns the result in an IntersectResult object.
|
||||
* @param point The Point or MicroPoint object to check, or any object with x and y properties.
|
||||
* @param point The Point or Point object to check, or any object with x and y properties.
|
||||
* @param rect The Rectangle object to check the point against
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
@@ -507,7 +506,8 @@ module Phaser {
|
||||
|
||||
output.setTo(point.x, point.y);
|
||||
|
||||
output.result = rect.containsPoint(point);
|
||||
//output.result = rect.containsPoint(point);
|
||||
|
||||
|
||||
return output;
|
||||
|
||||
@@ -591,7 +591,7 @@ module Phaser {
|
||||
/**
|
||||
* Checks if the Point object is contained within the Circle and returns the result in an IntersectResult object.
|
||||
* @param circle The Circle object to check
|
||||
* @param point A Point or MicroPoint object to check, or any object with x and y properties
|
||||
* @param point A Point or Point object to check, or any object with x and y properties
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
@@ -700,7 +700,7 @@ module Phaser {
|
||||
// Check if the X hulls actually overlap
|
||||
var objDeltaAbs: number = (objDelta > 0) ? objDelta : -objDelta;
|
||||
//var objDeltaAbs: number = object.collisionMask.deltaXAbs;
|
||||
var objBounds: Quad = new Quad(object.x - ((objDelta > 0) ? objDelta : 0), object.last.y, object.width + ((objDelta > 0) ? objDelta : -objDelta), object.height);
|
||||
var objBounds: Rectangle = new Rectangle(object.x - ((objDelta > 0) ? objDelta : 0), object.last.y, object.width + ((objDelta > 0) ? objDelta : -objDelta), object.height);
|
||||
|
||||
if ((objBounds.x + objBounds.width > x) && (objBounds.x < x + width) && (objBounds.y + objBounds.height > y) && (objBounds.y < y + height))
|
||||
{
|
||||
@@ -780,7 +780,7 @@ module Phaser {
|
||||
{
|
||||
// Check if the Y hulls actually overlap
|
||||
var objDeltaAbs: number = (objDelta > 0) ? objDelta : -objDelta;
|
||||
var objBounds: Quad = new Quad(object.x, object.y - ((objDelta > 0) ? objDelta : 0), object.width, object.height + objDeltaAbs);
|
||||
var objBounds: Rectangle = new Rectangle(object.x, object.y - ((objDelta > 0) ? objDelta : 0), object.width, object.height + objDeltaAbs);
|
||||
|
||||
if ((objBounds.x + objBounds.width > x) && (objBounds.x < x + width) && (objBounds.y + objBounds.height > y) && (objBounds.y < y + height))
|
||||
{
|
||||
@@ -858,7 +858,7 @@ module Phaser {
|
||||
{
|
||||
// Check if the X hulls actually overlap
|
||||
//var objDeltaAbs: number = (objDelta > 0) ? objDelta : -objDelta;
|
||||
//var objBounds: Quad = new Quad(object.x - ((objDelta > 0) ? objDelta : 0), object.last.y, object.width + ((objDelta > 0) ? objDelta : -objDelta), object.height);
|
||||
//var objBounds: Rectangle = new Rectangle(object.x - ((objDelta > 0) ? objDelta : 0), object.last.y, object.width + ((objDelta > 0) ? objDelta : -objDelta), object.height);
|
||||
|
||||
//if ((objBounds.x + objBounds.width > x) && (objBounds.x < x + width) && (objBounds.y + objBounds.height > y) && (objBounds.y < y + height))
|
||||
if (object.collisionMask.intersectsRaw(x, x + width, y, y + height))
|
||||
@@ -940,7 +940,7 @@ module Phaser {
|
||||
{
|
||||
// Check if the Y hulls actually overlap
|
||||
//var objDeltaAbs: number = (objDelta > 0) ? objDelta : -objDelta;
|
||||
//var objBounds: Quad = new Quad(object.x, object.y - ((objDelta > 0) ? objDelta : 0), object.width, object.height + objDeltaAbs);
|
||||
//var objBounds: Rectangle = new Rectangle(object.x, object.y - ((objDelta > 0) ? objDelta : 0), object.width, object.height + objDeltaAbs);
|
||||
|
||||
//if ((objBounds.x + objBounds.width > x) && (objBounds.x < x + width) && (objBounds.y + objBounds.height > y) && (objBounds.y < y + height))
|
||||
if (object.collisionMask.intersectsRaw(x, x + width, y, y + height))
|
||||
@@ -1263,7 +1263,7 @@ module Phaser {
|
||||
*
|
||||
* @type {Array.<Vector>}
|
||||
*/
|
||||
public static T_VECTORS: Vector2[];
|
||||
public static T_VECTORS: Vec2[];
|
||||
|
||||
/**
|
||||
* Pool of Arrays used in calculations.
|
||||
@@ -1399,7 +1399,7 @@ module Phaser {
|
||||
* MIDDLE_VORNOI_REGION (0) if it is the middle region,
|
||||
* RIGHT_VORNOI_REGION (1) if it is the right region.
|
||||
*/
|
||||
public static vornoiRegion(line: Vector2, point: Vector2): number {
|
||||
public static vornoiRegion(line: Vec2, point: Vec2): number {
|
||||
|
||||
var len2 = line.length2();
|
||||
var dp = point.dot(line);
|
||||
|
||||
Vendored
-32
@@ -1,32 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class DynamicTexture {
|
||||
constructor(game: Game, width: number, height: number);
|
||||
private _game;
|
||||
private _sx;
|
||||
private _sy;
|
||||
private _sw;
|
||||
private _sh;
|
||||
private _dx;
|
||||
private _dy;
|
||||
private _dw;
|
||||
private _dh;
|
||||
public bounds: Rectangle;
|
||||
public canvas: HTMLCanvasElement;
|
||||
public context: CanvasRenderingContext2D;
|
||||
public getPixel(x: number, y: number): number;
|
||||
public getPixel32(x: number, y: number): number;
|
||||
public getPixels(rect: Rectangle): ImageData;
|
||||
public setPixel(x: number, y: number, color: number): void;
|
||||
public setPixel32(x: number, y: number, color: number): void;
|
||||
public setPixels(rect: Rectangle, input): void;
|
||||
public fillRect(rect: Rectangle, color: number): void;
|
||||
public pasteImage(key: string, frame?: number, destX?: number, destY?: number, destWidth?: number, destHeight?: number): void;
|
||||
public copyPixels(sourceTexture: DynamicTexture, sourceRect: Rectangle, destPoint: Point): void;
|
||||
public clear(): void;
|
||||
public width : number;
|
||||
public height : number;
|
||||
private getColor32(alpha, red, green, blue);
|
||||
private getColor(red, green, blue);
|
||||
}
|
||||
}
|
||||
Vendored
-18
@@ -1,18 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class FXManager {
|
||||
constructor(game: Game);
|
||||
private _fx;
|
||||
private _length;
|
||||
private _game;
|
||||
public active: bool;
|
||||
public visible: bool;
|
||||
public add(effect): any;
|
||||
public preUpdate(): void;
|
||||
public postUpdate(): void;
|
||||
public preRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
public render(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
public postRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
public destroy(): void;
|
||||
}
|
||||
}
|
||||
Vendored
-88
@@ -1,88 +0,0 @@
|
||||
/// <reference path="AnimationManager.d.ts" />
|
||||
/// <reference path="Basic.d.ts" />
|
||||
/// <reference path="Cache.d.ts" />
|
||||
/// <reference path="CameraManager.d.ts" />
|
||||
/// <reference path="Collision.d.ts" />
|
||||
/// <reference path="DynamicTexture.d.ts" />
|
||||
/// <reference path="FXManager.d.ts" />
|
||||
/// <reference path="GameMath.d.ts" />
|
||||
/// <reference path="Group.d.ts" />
|
||||
/// <reference path="Loader.d.ts" />
|
||||
/// <reference path="Motion.d.ts" />
|
||||
/// <reference path="Signal.d.ts" />
|
||||
/// <reference path="SignalBinding.d.ts" />
|
||||
/// <reference path="SoundManager.d.ts" />
|
||||
/// <reference path="Stage.d.ts" />
|
||||
/// <reference path="Time.d.ts" />
|
||||
/// <reference path="TweenManager.d.ts" />
|
||||
/// <reference path="World.d.ts" />
|
||||
/// <reference path="system/Device.d.ts" />
|
||||
/// <reference path="system/RandomDataGenerator.d.ts" />
|
||||
/// <reference path="system/RequestAnimationFrame.d.ts" />
|
||||
/// <reference path="system/input/Input.d.ts" />
|
||||
/// <reference path="system/input/Keyboard.d.ts" />
|
||||
/// <reference path="system/input/Mouse.d.ts" />
|
||||
/// <reference path="system/input/Touch.d.ts" />
|
||||
/// <reference path="gameobjects/Emitter.d.ts" />
|
||||
/// <reference path="gameobjects/GameObject.d.ts" />
|
||||
/// <reference path="gameobjects/GeomSprite.d.ts" />
|
||||
/// <reference path="gameobjects/Particle.d.ts" />
|
||||
/// <reference path="gameobjects/Sprite.d.ts" />
|
||||
/// <reference path="gameobjects/Tilemap.d.ts" />
|
||||
/// <reference path="gameobjects/ScrollZone.d.ts" />
|
||||
module Phaser {
|
||||
class Game {
|
||||
constructor(callbackContext, parent?: string, width?: number, height?: number, initCallback?, createCallback?, updateCallback?, renderCallback?);
|
||||
private _raf;
|
||||
private _maxAccumulation;
|
||||
private _accumulator;
|
||||
private _step;
|
||||
private _loadComplete;
|
||||
private _paused;
|
||||
private _pendingState;
|
||||
public callbackContext;
|
||||
public onInitCallback;
|
||||
public onCreateCallback;
|
||||
public onUpdateCallback;
|
||||
public onRenderCallback;
|
||||
public onPausedCallback;
|
||||
public cache: Cache;
|
||||
public collision: Collision;
|
||||
public input: Input;
|
||||
public loader: Loader;
|
||||
public math: GameMath;
|
||||
public motion: Motion;
|
||||
public sound: SoundManager;
|
||||
public stage: Stage;
|
||||
public time: Time;
|
||||
public tweens: TweenManager;
|
||||
public world: World;
|
||||
public rnd: RandomDataGenerator;
|
||||
public device: Device;
|
||||
public isBooted: bool;
|
||||
public isRunning: bool;
|
||||
private boot(parent, width, height);
|
||||
private loadComplete();
|
||||
private bootLoop();
|
||||
private pausedLoop();
|
||||
private loop();
|
||||
private startState();
|
||||
public setCallbacks(initCallback?, createCallback?, updateCallback?, renderCallback?): void;
|
||||
public switchState(state, clearWorld?: bool, clearCache?: bool): void;
|
||||
public destroy(): void;
|
||||
public paused : bool;
|
||||
public framerate : number;
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera;
|
||||
public createGeomSprite(x: number, y: number): GeomSprite;
|
||||
public createSprite(x: number, y: number, key?: string): Sprite;
|
||||
public createDynamicTexture(width: number, height: number): DynamicTexture;
|
||||
public createGroup(MaxSize?: number): Group;
|
||||
public createParticle(): Particle;
|
||||
public createEmitter(x?: number, y?: number, size?: number): Emitter;
|
||||
public createScrollZone(key: string, x?: number, y?: number, width?: number, height?: number): ScrollZone;
|
||||
public createTilemap(key: string, mapData: string, format: number, resizeWorld?: bool, tileWidth?: number, tileHeight?: number): Tilemap;
|
||||
public createTween(obj): Tween;
|
||||
public collide(objectOrGroup1?: Basic, objectOrGroup2?: Basic, notifyCallback?): bool;
|
||||
public camera : Camera;
|
||||
}
|
||||
}
|
||||
+49
-47
@@ -1,39 +1,23 @@
|
||||
/// <reference path="AnimationManager.ts" />
|
||||
/// <reference path="Basic.ts" />
|
||||
/// <reference path="Cache.ts" />
|
||||
/// <reference path="CameraManager.ts" />
|
||||
/// <reference path="Collision.ts" />
|
||||
/// <reference path="DynamicTexture.ts" />
|
||||
/// <reference path="FXManager.ts" />
|
||||
/// <reference path="GameMath.ts" />
|
||||
/// <reference path="GameObjectFactory.ts" />
|
||||
/// <reference path="Group.ts" />
|
||||
/// <reference path="Loader.ts" />
|
||||
/// <reference path="Motion.ts" />
|
||||
/// <reference path="Signal.ts" />
|
||||
/// <reference path="SignalBinding.ts" />
|
||||
/// <reference path="SoundManager.ts" />
|
||||
/// <reference path="loader/Loader.ts" />
|
||||
/// <reference path="loader/Cache.ts" />
|
||||
/// <reference path="math/GameMath.ts" />
|
||||
/// <reference path="math/RandomDataGenerator.ts" />
|
||||
/// <reference path="cameras/CameraManager.ts" />
|
||||
/// <reference path="gameobjects/GameObjectFactory.ts" />
|
||||
/// <reference path="core/Group.ts" />
|
||||
/// <reference path="core/Signal.ts" />
|
||||
/// <reference path="core/SignalBinding.ts" />
|
||||
/// <reference path="sound/SoundManager.ts" />
|
||||
/// <reference path="Stage.ts" />
|
||||
/// <reference path="Time.ts" />
|
||||
/// <reference path="TweenManager.ts" />
|
||||
/// <reference path="VerletManager.ts" />
|
||||
/// <reference path="tweens/TweenManager.ts" />
|
||||
/// <reference path="World.ts" />
|
||||
/// <reference path="geom/Vector2.ts" />
|
||||
/// <reference path="system/Device.ts" />
|
||||
/// <reference path="system/RandomDataGenerator.ts" />
|
||||
/// <reference path="system/RequestAnimationFrame.ts" />
|
||||
/// <reference path="system/input/Input.ts" />
|
||||
/// <reference path="system/input/Keyboard.ts" />
|
||||
/// <reference path="system/input/Mouse.ts" />
|
||||
/// <reference path="system/input/MSPointer.ts" />
|
||||
/// <reference path="system/input/Touch.ts" />
|
||||
/// <reference path="gameobjects/Emitter.ts" />
|
||||
/// <reference path="gameobjects/GameObject.ts" />
|
||||
/// <reference path="gameobjects/GeomSprite.ts" />
|
||||
/// <reference path="gameobjects/Particle.ts" />
|
||||
/// <reference path="gameobjects/Sprite.ts" />
|
||||
/// <reference path="gameobjects/Tilemap.ts" />
|
||||
/// <reference path="gameobjects/ScrollZone.ts" />
|
||||
/// <reference path="input/Input.ts" />
|
||||
/// <reference path="renderers/IRenderer.ts" />
|
||||
/// <reference path="renderers/HeadlessRenderer.ts" />
|
||||
/// <reference path="renderers/CanvasRenderer.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Game
|
||||
@@ -189,7 +173,7 @@ module Phaser {
|
||||
* Reference to the collision helper.
|
||||
* @type {Collision}
|
||||
*/
|
||||
public collision: Collision;
|
||||
//public collision: Collision;
|
||||
|
||||
/**
|
||||
* Reference to the input manager
|
||||
@@ -213,7 +197,7 @@ module Phaser {
|
||||
* Reference to the motion helper.
|
||||
* @type {Motion}
|
||||
*/
|
||||
public motion: Motion;
|
||||
//public motion: Motion;
|
||||
|
||||
/**
|
||||
* Reference to the sound manager.
|
||||
@@ -239,12 +223,6 @@ module Phaser {
|
||||
*/
|
||||
public tweens: TweenManager;
|
||||
|
||||
/**
|
||||
* Reference to the verlet manager.
|
||||
* @type {VerletManager}
|
||||
*/
|
||||
public verlet: Phaser.Verlet.VerletManager;
|
||||
|
||||
/**
|
||||
* Reference to the world.
|
||||
* @type {World}
|
||||
@@ -263,6 +241,12 @@ module Phaser {
|
||||
*/
|
||||
public device: Device;
|
||||
|
||||
/**
|
||||
* Reference to the render manager
|
||||
* @type {RenderManager}
|
||||
*/
|
||||
public renderer: IRenderer;
|
||||
|
||||
/**
|
||||
* Whether the game engine is booted, aka available.
|
||||
* @type {boolean}
|
||||
@@ -295,20 +279,21 @@ module Phaser {
|
||||
else
|
||||
{
|
||||
this.device = new Device();
|
||||
this.motion = new Motion(this);
|
||||
//this.motion = new Motion(this);
|
||||
this.math = new GameMath(this);
|
||||
this.stage = new Stage(this, parent, width, height);
|
||||
this.world = new World(this, width, height);
|
||||
this.add = new GameObjectFactory(this);
|
||||
this.sound = new SoundManager(this);
|
||||
this.cache = new Cache(this);
|
||||
this.collision = new Collision(this);
|
||||
//this.collision = new Collision(this);
|
||||
this.loader = new Loader(this, this.loadComplete);
|
||||
this.time = new Time(this);
|
||||
this.tweens = new TweenManager(this);
|
||||
this.input = new Input(this);
|
||||
this.rnd = new RandomDataGenerator([(Date.now() * Math.random()).toString()]);
|
||||
this.verlet = new Phaser.Verlet.VerletManager(this, width, height);
|
||||
|
||||
this.setRenderer(Phaser.Types.RENDERER_CANVAS);
|
||||
|
||||
this.framerate = 60;
|
||||
this.isBooted = true;
|
||||
@@ -341,6 +326,24 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
public setRenderer(type: number) {
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case Phaser.Types.RENDERER_AUTO_DETECT:
|
||||
this.renderer = new Phaser.HeadlessRenderer(this);
|
||||
break;
|
||||
|
||||
case Phaser.Types.RENDERER_AUTO_DETECT:
|
||||
case Phaser.Types.RENDERER_CANVAS:
|
||||
this.renderer = new Phaser.CanvasRenderer(this);
|
||||
break;
|
||||
|
||||
// WebGL coming soon :)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the loader has finished after init was run.
|
||||
*/
|
||||
@@ -385,7 +388,6 @@ module Phaser {
|
||||
this.tweens.update();
|
||||
this.input.update();
|
||||
this.stage.update();
|
||||
this.verlet.update();
|
||||
|
||||
this._accumulator += this.time.delta;
|
||||
|
||||
@@ -406,7 +408,7 @@ module Phaser {
|
||||
this.onUpdateCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
this.world.render();
|
||||
this.renderer.render();
|
||||
|
||||
if (this._loadComplete && this.onRenderCallback)
|
||||
{
|
||||
@@ -637,9 +639,9 @@ module Phaser {
|
||||
* @param context The context in which the callbacks will be called
|
||||
* @returns {boolean} true if the objects overlap, otherwise false.
|
||||
*/
|
||||
public collide(objectOrGroup1: Basic = null, objectOrGroup2: Basic = null, notifyCallback = null, context? = this.callbackContext): bool {
|
||||
return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate, context);
|
||||
}
|
||||
//public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.callbackContext): bool {
|
||||
// return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate, context);
|
||||
//}
|
||||
|
||||
public get camera(): Camera {
|
||||
return this.world.cameras.current;
|
||||
|
||||
Vendored
-110
@@ -1,110 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class GameMath {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
static PI: number;
|
||||
static PI_2: number;
|
||||
static PI_4: number;
|
||||
static PI_8: number;
|
||||
static PI_16: number;
|
||||
static TWO_PI: number;
|
||||
static THREE_PI_2: number;
|
||||
static E: number;
|
||||
static LN10: number;
|
||||
static LN2: number;
|
||||
static LOG10E: number;
|
||||
static LOG2E: number;
|
||||
static SQRT1_2: number;
|
||||
static SQRT2: number;
|
||||
static DEG_TO_RAD: number;
|
||||
static RAD_TO_DEG: number;
|
||||
static B_16: number;
|
||||
static B_31: number;
|
||||
static B_32: number;
|
||||
static B_48: number;
|
||||
static B_53: number;
|
||||
static B_64: number;
|
||||
static ONE_THIRD: number;
|
||||
static TWO_THIRDS: number;
|
||||
static ONE_SIXTH: number;
|
||||
static COS_PI_3: number;
|
||||
static SIN_2PI_3: number;
|
||||
static CIRCLE_ALPHA: number;
|
||||
static ON: bool;
|
||||
static OFF: bool;
|
||||
static SHORT_EPSILON: number;
|
||||
static PERC_EPSILON: number;
|
||||
static EPSILON: number;
|
||||
static LONG_EPSILON: number;
|
||||
public cosTable: any[];
|
||||
public sinTable: any[];
|
||||
public fuzzyEqual(a: number, b: number, epsilon?: number): bool;
|
||||
public fuzzyLessThan(a: number, b: number, epsilon?: number): bool;
|
||||
public fuzzyGreaterThan(a: number, b: number, epsilon?: number): bool;
|
||||
public fuzzyCeil(val: number, epsilon?: number): number;
|
||||
public fuzzyFloor(val: number, epsilon?: number): number;
|
||||
public average(...args: any[]): number;
|
||||
public slam(value: number, target: number, epsilon?: number): number;
|
||||
public percentageMinMax(val: number, max: number, min?: number): number;
|
||||
public sign(n: number): number;
|
||||
public truncate(n: number): number;
|
||||
public shear(n: number): number;
|
||||
public wrap(val: number, max: number, min?: number): number;
|
||||
public arithWrap(value: number, max: number, min?: number): number;
|
||||
public clamp(input: number, max: number, min?: number): number;
|
||||
public snapTo(input: number, gap: number, start?: number): number;
|
||||
public snapToFloor(input: number, gap: number, start?: number): number;
|
||||
public snapToCeil(input: number, gap: number, start?: number): number;
|
||||
public snapToInArray(input: number, arr: number[], sort?: bool): number;
|
||||
public roundTo(value: number, place?: number, base?: number): number;
|
||||
public floorTo(value: number, place?: number, base?: number): number;
|
||||
public ceilTo(value: number, place?: number, base?: number): number;
|
||||
public interpolateFloat(a: number, b: number, weight: number): number;
|
||||
public radiansToDegrees(angle: number): number;
|
||||
public degreesToRadians(angle: number): number;
|
||||
public angleBetween(x1: number, y1: number, x2: number, y2: number): number;
|
||||
public normalizeAngle(angle: number, radians?: bool): number;
|
||||
public nearestAngleBetween(a1: number, a2: number, radians?: bool): number;
|
||||
public normalizeAngleToAnother(dep: number, ind: number, radians?: bool): number;
|
||||
public normalizeAngleAfterAnother(dep: number, ind: number, radians?: bool): number;
|
||||
public normalizeAngleBeforeAnother(dep: number, ind: number, radians?: bool): number;
|
||||
public interpolateAngles(a1: number, a2: number, weight: number, radians?: bool, ease?): number;
|
||||
public logBaseOf(value: number, base: number): number;
|
||||
public GCD(m: number, n: number): number;
|
||||
public LCM(m: number, n: number): number;
|
||||
public factorial(value: number): number;
|
||||
public gammaFunction(value: number): number;
|
||||
public fallingFactorial(base: number, exp: number): number;
|
||||
public risingFactorial(base: number, exp: number): number;
|
||||
public binCoef(n: number, k: number): number;
|
||||
public risingBinCoef(n: number, k: number): number;
|
||||
public chanceRoll(chance?: number): bool;
|
||||
public maxAdd(value: number, amount: number, max: number): number;
|
||||
public minSub(value: number, amount: number, min: number): number;
|
||||
public wrapValue(value: number, amount: number, max: number): number;
|
||||
public randomSign(): number;
|
||||
public isOdd(n: number): bool;
|
||||
public isEven(n: number): bool;
|
||||
public wrapAngle(angle: number): number;
|
||||
public angleLimit(angle: number, min: number, max: number): number;
|
||||
public linearInterpolation(v, k);
|
||||
public bezierInterpolation(v, k): number;
|
||||
public catmullRomInterpolation(v, k);
|
||||
public linear(p0, p1, t);
|
||||
public bernstein(n, i): number;
|
||||
public catmullRom(p0, p1, p2, p3, t);
|
||||
public difference(a: number, b: number): number;
|
||||
public globalSeed: number;
|
||||
public random(): number;
|
||||
public srand(Seed: number): number;
|
||||
public getRandom(Objects, StartIndex?: number, Length?: number);
|
||||
public floor(Value: number): number;
|
||||
public ceil(Value: number): number;
|
||||
public sinCosGenerator(length: number, sinAmplitude?: number, cosAmplitude?: number, frequency?: number): any[];
|
||||
public shiftSinTable(): number;
|
||||
public shiftCosTable(): number;
|
||||
public vectorLength(dx: number, dy: number): number;
|
||||
public dotProduct(ax: number, ay: number, bx: number, by: number): number;
|
||||
}
|
||||
}
|
||||
Vendored
-39
@@ -1,39 +0,0 @@
|
||||
/// <reference path="Basic.d.ts" />
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class Group extends Basic {
|
||||
constructor(game: Game, MaxSize?: number);
|
||||
static ASCENDING: number;
|
||||
static DESCENDING: number;
|
||||
public members: Basic[];
|
||||
public length: number;
|
||||
private _maxSize;
|
||||
private _marker;
|
||||
private _sortIndex;
|
||||
private _sortOrder;
|
||||
public destroy(): void;
|
||||
public update(): void;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
|
||||
public maxSize : number;
|
||||
public add(Object: Basic): Basic;
|
||||
public recycle(ObjectClass?);
|
||||
public remove(Object: Basic, Splice?: bool): Basic;
|
||||
public replace(OldObject: Basic, NewObject: Basic): Basic;
|
||||
public sort(Index?: string, Order?: number): void;
|
||||
public setAll(VariableName: string, Value: Object, Recurse?: bool): void;
|
||||
public callAll(FunctionName: string, Recurse?: bool): void;
|
||||
public forEach(callback, recursive?: bool): void;
|
||||
public forEachAlive(context, callback, recursive?: bool): void;
|
||||
public getFirstAvailable(ObjectClass?);
|
||||
public getFirstNull(): number;
|
||||
public getFirstExtant(): Basic;
|
||||
public getFirstAlive(): Basic;
|
||||
public getFirstDead(): Basic;
|
||||
public countLiving(): number;
|
||||
public countDead(): number;
|
||||
public getRandom(StartIndex?: number, Length?: number): Basic;
|
||||
public clear(): void;
|
||||
public kill(): void;
|
||||
public sortHandler(Obj1: Basic, Obj2: Basic): number;
|
||||
}
|
||||
}
|
||||
Vendored
-34
@@ -1,34 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class Loader {
|
||||
constructor(game: Game, callback);
|
||||
private _game;
|
||||
private _keys;
|
||||
private _fileList;
|
||||
private _gameCreateComplete;
|
||||
private _onComplete;
|
||||
private _onFileLoad;
|
||||
private _progressChunk;
|
||||
private _xhr;
|
||||
private _queueSize;
|
||||
public hasLoaded: bool;
|
||||
public progress: number;
|
||||
public reset(): void;
|
||||
public queueSize : number;
|
||||
public addImageFile(key: string, url: string): void;
|
||||
public addSpriteSheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax?: number): void;
|
||||
public addTextureAtlas(key: string, url: string, jsonURL?: string, jsonData?): void;
|
||||
public addAudioFile(key: string, url: string): void;
|
||||
public addTextFile(key: string, url: string): void;
|
||||
public removeFile(key: string): void;
|
||||
public removeAll(): void;
|
||||
public load(onFileLoadCallback?, onCompleteCallback?): void;
|
||||
private loadFile();
|
||||
private fileError(key);
|
||||
private fileComplete(key);
|
||||
private jsonLoadComplete(key);
|
||||
private jsonLoadError(key);
|
||||
private nextFile(previousKey, success);
|
||||
private checkKeyExists(key);
|
||||
}
|
||||
}
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="gameobjects/GameObject.d.ts" />
|
||||
module Phaser {
|
||||
class Motion {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
public computeVelocity(Velocity: number, Acceleration?: number, Drag?: number, Max?: number): number;
|
||||
public velocityFromAngle(angle: number, speed: number): Point;
|
||||
public moveTowardsObject(source: GameObject, dest: GameObject, speed?: number, maxTime?: number): void;
|
||||
public accelerateTowardsObject(source: GameObject, dest: GameObject, speed: number, xSpeedMax: number, ySpeedMax: number): void;
|
||||
public moveTowardsMouse(source: GameObject, speed?: number, maxTime?: number): void;
|
||||
public accelerateTowardsMouse(source: GameObject, speed: number, xSpeedMax: number, ySpeedMax: number): void;
|
||||
public moveTowardsPoint(source: GameObject, target: Point, speed?: number, maxTime?: number): void;
|
||||
public accelerateTowardsPoint(source: GameObject, target: Point, speed: number, xSpeedMax: number, ySpeedMax: number): void;
|
||||
public distanceBetween(a: GameObject, b: GameObject): number;
|
||||
public distanceToPoint(a: GameObject, target: Point): number;
|
||||
public distanceToMouse(a: GameObject): number;
|
||||
public angleBetweenPoint(a: GameObject, target: Point, asDegrees?: bool): number;
|
||||
public angleBetween(a: GameObject, b: GameObject, asDegrees?: bool): number;
|
||||
public velocityFromFacing(parent: GameObject, speed: number): Point;
|
||||
public angleBetweenMouse(a: GameObject, asDegrees?: bool): number;
|
||||
}
|
||||
}
|
||||
+75
-95
@@ -58,18 +58,23 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Content Include="animation\AnimationManager.js">
|
||||
<Content Include="components\animation\AnimationManager.js">
|
||||
<DependentUpon>AnimationManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="cameras\OrthographicCamera.ts" />
|
||||
<Content Include="cameras\OrthographicCamera.js">
|
||||
<DependentUpon>OrthographicCamera.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Collision.js">
|
||||
<DependentUpon>Collision.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="core\Rectangle.ts" />
|
||||
<TypeScriptCompile Include="core\Point.ts" />
|
||||
<TypeScriptCompile Include="components\sprite\Texture.ts" />
|
||||
<TypeScriptCompile Include="components\sprite\Position.ts" />
|
||||
<TypeScriptCompile Include="components\camera\CameraFX.ts" />
|
||||
<Content Include="components\camera\CameraFX.js">
|
||||
<DependentUpon>CameraFX.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="components\sprite\Position.js">
|
||||
<DependentUpon>Position.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="components\sprite\Texture.js">
|
||||
<DependentUpon>Texture.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="core\Point.js">
|
||||
<DependentUpon>Point.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -80,64 +85,58 @@
|
||||
<Content Include="core\Vec2.js">
|
||||
<DependentUpon>Vec2.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="DynamicTexture.js">
|
||||
<Content Include="gameobjects\DynamicTexture.js">
|
||||
<DependentUpon>DynamicTexture.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="FXManager.ts" />
|
||||
<Content Include="FXManager.js">
|
||||
<DependentUpon>FXManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Game.js">
|
||||
<DependentUpon>Game.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="GameMath.js">
|
||||
<TypeScriptCompile Include="gameobjects\Sprite.ts" />
|
||||
<Content Include="math\GameMath.js">
|
||||
<DependentUpon>GameMath.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="GameObjectFactory.ts" />
|
||||
<Content Include="GameObjectFactory.js">
|
||||
<TypeScriptCompile Include="gameobjects\GameObjectFactory.ts" />
|
||||
<Content Include="gameobjects\GameObjectFactory.js">
|
||||
<DependentUpon>GameObjectFactory.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Emitter.js">
|
||||
<DependentUpon>Emitter.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\GameObject.js">
|
||||
<DependentUpon>GameObject.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\GeomSprite.js">
|
||||
<DependentUpon>GeomSprite.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Particle.js">
|
||||
<DependentUpon>Particle.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="gameobjects\ScrollZone.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\ScrollRegion.ts" />
|
||||
<Content Include="gameobjects\ScrollRegion.js">
|
||||
<TypeScriptCompile Include="components\ScrollRegion.ts" />
|
||||
<Content Include="components\ScrollRegion.js">
|
||||
<DependentUpon>ScrollRegion.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\ScrollZone.js">
|
||||
<DependentUpon>ScrollZone.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Sprite.js">
|
||||
<DependentUpon>Sprite.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Tilemap.js">
|
||||
<DependentUpon>Tilemap.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geom\Polygon.ts" />
|
||||
<TypeScriptCompile Include="geom\PointUtils.ts" />
|
||||
<TypeScriptCompile Include="geom\CircleUtils.ts" />
|
||||
<Content Include="geom\CircleUtils.js">
|
||||
<TypeScriptCompile Include="utils\PointUtils.ts" />
|
||||
<TypeScriptCompile Include="utils\CircleUtils.ts" />
|
||||
<TypeScriptCompile Include="renderers\CanvasRenderer.ts" />
|
||||
<TypeScriptCompile Include="Statics.ts" />
|
||||
<TypeScriptCompile Include="renderers\HeadlessRenderer.ts" />
|
||||
<Content Include="renderers\HeadlessRenderer.js">
|
||||
<DependentUpon>HeadlessRenderer.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="renderers\IRenderer.ts" />
|
||||
<Content Include="renderers\IRenderer.js">
|
||||
<DependentUpon>IRenderer.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Statics.js">
|
||||
<DependentUpon>Statics.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="renderers\CanvasRenderer.js">
|
||||
<DependentUpon>CanvasRenderer.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="utils\CircleUtils.js">
|
||||
<DependentUpon>CircleUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\PointUtils.js">
|
||||
<Content Include="utils\PointUtils.js">
|
||||
<DependentUpon>PointUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Polygon.js">
|
||||
<DependentUpon>Polygon.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geom\Response.ts" />
|
||||
<TypeScriptCompile Include="geom\RectangleUtils.ts" />
|
||||
<Content Include="geom\RectangleUtils.js">
|
||||
<TypeScriptCompile Include="utils\RectangleUtils.ts" />
|
||||
<Content Include="utils\RectangleUtils.js">
|
||||
<DependentUpon>RectangleUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Response.js">
|
||||
@@ -152,14 +151,10 @@
|
||||
<Content Include="geom\Line.js">
|
||||
<DependentUpon>Line.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geom\Vec2Utils.ts" />
|
||||
<Content Include="geom\Vec2Utils.js">
|
||||
<TypeScriptCompile Include="math\Vec2Utils.ts" />
|
||||
<Content Include="math\Vec2Utils.js">
|
||||
<DependentUpon>Vec2Utils.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="math\Vector2.ts" />
|
||||
<Content Include="math\Vector2.js">
|
||||
<DependentUpon>Vector2.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="sound\SoundManager.js">
|
||||
<DependentUpon>SoundManager.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -167,10 +162,6 @@
|
||||
<TypeScriptCompile Include="system\screens\BootScreen.ts" />
|
||||
<TypeScriptCompile Include="input\MSPointer.ts" />
|
||||
<TypeScriptCompile Include="input\Gestures.ts" />
|
||||
<TypeScriptCompile Include="system\CollisionMask.ts" />
|
||||
<Content Include="system\CollisionMask.js">
|
||||
<DependentUpon>CollisionMask.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="input\Gestures.js">
|
||||
<DependentUpon>Gestures.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -192,16 +183,16 @@
|
||||
</Content>
|
||||
<TypeScriptCompile Include="sound\Sound.ts" />
|
||||
<TypeScriptCompile Include="sound\SoundManager.ts" />
|
||||
<Content Include="animation\Animation.js">
|
||||
<Content Include="components\animation\Animation.js">
|
||||
<DependentUpon>Animation.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="animation\AnimationLoader.js">
|
||||
<Content Include="loader\AnimationLoader.js">
|
||||
<DependentUpon>AnimationLoader.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="animation\Frame.js">
|
||||
<Content Include="components\animation\Frame.js">
|
||||
<DependentUpon>Frame.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="animation\FrameData.js">
|
||||
<Content Include="components\animation\FrameData.js">
|
||||
<DependentUpon>FrameData.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="cameras\Camera.js">
|
||||
@@ -210,13 +201,13 @@
|
||||
<Content Include="system\Device.js">
|
||||
<DependentUpon>Device.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\LinkedList.js">
|
||||
<Content Include="math\LinkedList.js">
|
||||
<DependentUpon>LinkedList.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\QuadTree.js">
|
||||
<Content Include="math\QuadTree.js">
|
||||
<DependentUpon>QuadTree.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\RandomDataGenerator.js">
|
||||
<Content Include="math\RandomDataGenerator.js">
|
||||
<DependentUpon>RandomDataGenerator.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\RequestAnimationFrame.js">
|
||||
@@ -225,23 +216,23 @@
|
||||
<Content Include="system\StageScaleMode.js">
|
||||
<DependentUpon>StageScaleMode.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\Tile.js">
|
||||
<Content Include="components\Tile.js">
|
||||
<DependentUpon>Tile.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="system\TilemapLayer.ts" />
|
||||
<Content Include="system\TilemapLayer.js">
|
||||
<TypeScriptCompile Include="components\TilemapLayer.ts" />
|
||||
<Content Include="components\TilemapLayer.js">
|
||||
<DependentUpon>TilemapLayer.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tweens\Tween.js">
|
||||
<DependentUpon>Tween.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tweens\Tween.ts" />
|
||||
<TypeScriptCompile Include="system\Tile.ts" />
|
||||
<TypeScriptCompile Include="components\Tile.ts" />
|
||||
<TypeScriptCompile Include="system\StageScaleMode.ts" />
|
||||
<TypeScriptCompile Include="system\RequestAnimationFrame.ts" />
|
||||
<TypeScriptCompile Include="system\RandomDataGenerator.ts" />
|
||||
<TypeScriptCompile Include="system\QuadTree.ts" />
|
||||
<TypeScriptCompile Include="system\LinkedList.ts" />
|
||||
<TypeScriptCompile Include="math\RandomDataGenerator.ts" />
|
||||
<TypeScriptCompile Include="math\QuadTree.ts" />
|
||||
<TypeScriptCompile Include="math\LinkedList.ts" />
|
||||
<TypeScriptCompile Include="system\Device.ts" />
|
||||
<TypeScriptCompile Include="cameras\Camera.ts" />
|
||||
<Content Include="tweens\easing\Back.js">
|
||||
@@ -304,35 +295,26 @@
|
||||
<TypeScriptCompile Include="tweens\easing\Circular.ts" />
|
||||
<TypeScriptCompile Include="tweens\easing\Bounce.ts" />
|
||||
<TypeScriptCompile Include="tweens\easing\Back.ts" />
|
||||
<TypeScriptCompile Include="animation\FrameData.ts" />
|
||||
<TypeScriptCompile Include="animation\Frame.ts" />
|
||||
<TypeScriptCompile Include="animation\AnimationLoader.ts" />
|
||||
<TypeScriptCompile Include="animation\Animation.ts" />
|
||||
<TypeScriptCompile Include="components\animation\FrameData.ts" />
|
||||
<TypeScriptCompile Include="components\animation\Frame.ts" />
|
||||
<TypeScriptCompile Include="loader\AnimationLoader.ts" />
|
||||
<TypeScriptCompile Include="components\animation\Animation.ts" />
|
||||
<TypeScriptCompile Include="geom\Line.ts" />
|
||||
<TypeScriptCompile Include="geom\IntersectResult.ts" />
|
||||
<TypeScriptCompile Include="core\Circle.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Tilemap.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Sprite.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Particle.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\GeomSprite.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\GameObject.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Emitter.ts" />
|
||||
<Content Include="Group.js">
|
||||
<Content Include="core\Group.js">
|
||||
<DependentUpon>Group.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="loader\Loader.js">
|
||||
<DependentUpon>Loader.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Motion.js">
|
||||
<DependentUpon>Motion.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Phaser.js">
|
||||
<DependentUpon>Phaser.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Signal.js">
|
||||
<Content Include="core\Signal.js">
|
||||
<DependentUpon>Signal.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="SignalBinding.js">
|
||||
<Content Include="core\SignalBinding.js">
|
||||
<DependentUpon>SignalBinding.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Stage.js">
|
||||
@@ -347,6 +329,10 @@
|
||||
<Content Include="tweens\TweenManager.js">
|
||||
<DependentUpon>TweenManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="utils\SpriteUtils.ts" />
|
||||
<Content Include="utils\SpriteUtils.js">
|
||||
<DependentUpon>SpriteUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="World.js">
|
||||
<DependentUpon>World.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -355,20 +341,15 @@
|
||||
<TypeScriptCompile Include="Time.ts" />
|
||||
<TypeScriptCompile Include="State.ts" />
|
||||
<TypeScriptCompile Include="Stage.ts" />
|
||||
<TypeScriptCompile Include="SignalBinding.ts" />
|
||||
<TypeScriptCompile Include="Signal.ts" />
|
||||
<TypeScriptCompile Include="core\SignalBinding.ts" />
|
||||
<TypeScriptCompile Include="core\Signal.ts" />
|
||||
<TypeScriptCompile Include="Phaser.ts" />
|
||||
<TypeScriptCompile Include="Motion.ts" />
|
||||
<TypeScriptCompile Include="loader\Loader.ts" />
|
||||
<TypeScriptCompile Include="Group.ts" />
|
||||
<TypeScriptCompile Include="GameMath.ts" />
|
||||
<TypeScriptCompile Include="core\Group.ts" />
|
||||
<TypeScriptCompile Include="math\GameMath.ts" />
|
||||
<TypeScriptCompile Include="Game.ts" />
|
||||
<TypeScriptCompile Include="DynamicTexture.ts" />
|
||||
<TypeScriptCompile Include="Collision.ts" />
|
||||
<TypeScriptCompile Include="animation\AnimationManager.ts" />
|
||||
<Content Include="Basic.js">
|
||||
<DependentUpon>Basic.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="gameobjects\DynamicTexture.ts" />
|
||||
<TypeScriptCompile Include="components\animation\AnimationManager.ts" />
|
||||
<Content Include="loader\Cache.js">
|
||||
<DependentUpon>Cache.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -377,7 +358,6 @@
|
||||
</Content>
|
||||
<TypeScriptCompile Include="cameras\CameraManager.ts" />
|
||||
<TypeScriptCompile Include="loader\Cache.ts" />
|
||||
<TypeScriptCompile Include="Basic.ts" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
|
||||
<PropertyGroup>
|
||||
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
module Phaser {
|
||||
var VERSION: string;
|
||||
}
|
||||
+4
-3
@@ -1,13 +1,14 @@
|
||||
/**
|
||||
* Phaser
|
||||
*
|
||||
* v0.9.6 - May 21st 2013
|
||||
* v1.0.0 - June XX 2013
|
||||
*
|
||||
* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
|
||||
*
|
||||
* Richard Davey (@photonstorm)
|
||||
*
|
||||
* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel on which Phaser took a lot of inspiration.
|
||||
* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from both which Phaser
|
||||
* and my love of game development took a lot of inspiration.
|
||||
*
|
||||
* "If you want your children to be intelligent, read them fairy tales."
|
||||
* "If you want them to be more intelligent, read them more fairy tales."
|
||||
@@ -16,6 +17,6 @@
|
||||
|
||||
module Phaser {
|
||||
|
||||
export var VERSION: string = 'Phaser version 0.9.6';
|
||||
export var VERSION: string = 'Phaser version 1.0.0';
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// Interface
|
||||
interface IPoint {
|
||||
getDist(): number;
|
||||
}
|
||||
|
||||
// Module
|
||||
module Shapes {
|
||||
|
||||
// Class
|
||||
export class Point implements IPoint {
|
||||
// Constructor
|
||||
constructor (public x: number, public y: number) { }
|
||||
|
||||
// Instance member
|
||||
getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); }
|
||||
|
||||
// Static member
|
||||
static origin = new Point(0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Local variables
|
||||
var p: IPoint = new Shapes.Point(3, 4);
|
||||
var dist = p.getDist();
|
||||
Vendored
-26
@@ -1,26 +0,0 @@
|
||||
/// <reference path="SignalBinding.d.ts" />
|
||||
module Phaser {
|
||||
class Signal {
|
||||
private _bindings;
|
||||
private _prevParams;
|
||||
static VERSION: string;
|
||||
public memorize: bool;
|
||||
private _shouldPropagate;
|
||||
public active: bool;
|
||||
public validateListener(listener, fnName): void;
|
||||
private _registerListener(listener, isOnce, listenerContext, priority);
|
||||
private _addBinding(binding);
|
||||
private _indexOfListener(listener, context);
|
||||
public has(listener, context?: any): bool;
|
||||
public add(listener, listenerContext?: any, priority?: number): SignalBinding;
|
||||
public addOnce(listener, listenerContext?: any, priority?: number): SignalBinding;
|
||||
public remove(listener, context?: any);
|
||||
public removeAll(): void;
|
||||
public getNumListeners(): number;
|
||||
public halt(): void;
|
||||
public dispatch(...paramsArr: any[]): void;
|
||||
public forget(): void;
|
||||
public dispose(): void;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
/// <reference path="Signal.d.ts" />
|
||||
module Phaser {
|
||||
class SignalBinding {
|
||||
constructor(signal: Signal, listener, isOnce: bool, listenerContext, priority?: number);
|
||||
private _listener;
|
||||
private _isOnce;
|
||||
public context;
|
||||
private _signal;
|
||||
public priority: number;
|
||||
public active: bool;
|
||||
public params;
|
||||
public execute(paramsArr?: any[]);
|
||||
public detach();
|
||||
public isBound(): bool;
|
||||
public isOnce(): bool;
|
||||
public getListener();
|
||||
public getSignal(): Signal;
|
||||
public _destroy(): void;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="system/Sound.d.ts" />
|
||||
module Phaser {
|
||||
class SoundManager {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _context;
|
||||
private _gainNode;
|
||||
private _volume;
|
||||
public mute(): void;
|
||||
public unmute(): void;
|
||||
public volume : number;
|
||||
public decode(key: string, callback?, sound?: Sound): void;
|
||||
public play(key: string, volume?: number, loop?: bool): Sound;
|
||||
}
|
||||
}
|
||||
Vendored
-47
@@ -1,47 +0,0 @@
|
||||
/// <reference path="Phaser.d.ts" />
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="system/StageScaleMode.d.ts" />
|
||||
/// <reference path="system/screens/BootScreen.d.ts" />
|
||||
/// <reference path="system/screens/PauseScreen.d.ts" />
|
||||
module Phaser {
|
||||
class Stage {
|
||||
constructor(game: Game, parent: string, width: number, height: number);
|
||||
private _game;
|
||||
private _bgColor;
|
||||
private _bootScreen;
|
||||
private _pauseScreen;
|
||||
static ORIENTATION_LANDSCAPE: number;
|
||||
static ORIENTATION_PORTRAIT: number;
|
||||
public bounds: Rectangle;
|
||||
public aspectRatio: number;
|
||||
public clear: bool;
|
||||
public canvas: HTMLCanvasElement;
|
||||
public context: CanvasRenderingContext2D;
|
||||
public disablePauseScreen: bool;
|
||||
public disableBootScreen: bool;
|
||||
public offset: Point;
|
||||
public scale: StageScaleMode;
|
||||
public scaleMode: number;
|
||||
public minScaleX: number;
|
||||
public maxScaleX: number;
|
||||
public minScaleY: number;
|
||||
public maxScaleY: number;
|
||||
public update(): void;
|
||||
private visibilityChange(event);
|
||||
private getOffset(element);
|
||||
public strokeStyle: string;
|
||||
public lineWidth: number;
|
||||
public fillStyle: string;
|
||||
public saveCanvasValues(): void;
|
||||
public restoreCanvasValues(): void;
|
||||
public backgroundColor : string;
|
||||
public x : number;
|
||||
public y : number;
|
||||
public width : number;
|
||||
public height : number;
|
||||
public centerX : number;
|
||||
public centerY : number;
|
||||
public randomX : number;
|
||||
public randomY : number;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -52,7 +52,7 @@ module Phaser {
|
||||
this.context = this.canvas.getContext('2d');
|
||||
|
||||
this.offset = this.getOffset(this.canvas);
|
||||
this.bounds = new Quad(this.offset.x, this.offset.y, width, height);
|
||||
this.bounds = new Rectangle(this.offset.x, this.offset.y, width, height);
|
||||
this.aspectRatio = width / height;
|
||||
this.scaleMode = StageScaleMode.NO_SCALE;
|
||||
this.scale = new StageScaleMode(this._game);
|
||||
@@ -92,9 +92,9 @@ module Phaser {
|
||||
|
||||
/**
|
||||
* Bound of this stage.
|
||||
* @type {Quad}
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public bounds: Quad;
|
||||
public bounds: Rectangle;
|
||||
|
||||
/**
|
||||
* Asperct ratio, thus: width / height.
|
||||
@@ -138,7 +138,7 @@ module Phaser {
|
||||
* Offset from this stage to the canvas element.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public offset: MicroPoint;
|
||||
public offset: Point;
|
||||
|
||||
/**
|
||||
* This object manages scaling of the game, see(StageScaleMode).
|
||||
@@ -227,7 +227,7 @@ module Phaser {
|
||||
/**
|
||||
* Get the DOM offset values of the given element
|
||||
*/
|
||||
private getOffset(element): MicroPoint {
|
||||
private getOffset(element): Point {
|
||||
|
||||
var box = element.getBoundingClientRect();
|
||||
|
||||
@@ -236,7 +236,7 @@ module Phaser {
|
||||
var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop;
|
||||
var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft;
|
||||
|
||||
return new MicroPoint(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop);
|
||||
return new Point(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ module Phaser {
|
||||
* @param context The context in which the callbacks will be called
|
||||
* @returns {boolean} true if the objects overlap, otherwise false.
|
||||
*/
|
||||
public collide(objectOrGroup1: Basic = null, objectOrGroup2: Basic = null, notifyCallback = null, context? = this.game.callbackContext): bool {
|
||||
public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.game.callbackContext): bool {
|
||||
return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
module Phaser {
|
||||
|
||||
/**
|
||||
* Constants used to define game object types (faster than doing typeof object checks in core loops)
|
||||
*/
|
||||
export class Types {
|
||||
|
||||
static RENDERER_AUTO_DETECT: number = 0;
|
||||
static RENDERER_HEADLESS: number = 1;
|
||||
static RENDERER_CANVAS: number = 2;
|
||||
static RENDERER_WEBGL: number = 3;
|
||||
|
||||
static GROUP: number = 0;
|
||||
static SPRITE: number = 1;
|
||||
static GEOMSPRITE: number = 2;
|
||||
static PARTICLE: number = 3;
|
||||
static EMITTER: number = 4;
|
||||
static TILEMAP: number = 5;
|
||||
static SCROLLZONE: number = 6;
|
||||
|
||||
static GEOM_POINT: number = 0;
|
||||
static GEOM_CIRCLE: number = 1;
|
||||
static GEOM_RECTANGLE: number = 2;
|
||||
static GEOM_LINE: number = 3;
|
||||
static GEOM_POLYGON: number = 4;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-25
@@ -1,25 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class Time {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _started;
|
||||
public timeScale: number;
|
||||
public elapsed: number;
|
||||
public time: number;
|
||||
public now: number;
|
||||
public delta: number;
|
||||
public totalElapsedSeconds : number;
|
||||
public fps: number;
|
||||
public fpsMin: number;
|
||||
public fpsMax: number;
|
||||
public msMin: number;
|
||||
public msMax: number;
|
||||
public frames: number;
|
||||
private _timeLastSecond;
|
||||
public update(): void;
|
||||
public elapsedSince(since: number): number;
|
||||
public elapsedSecondsSince(since: number): number;
|
||||
public reset(): void;
|
||||
}
|
||||
}
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="system/Tween.d.ts" />
|
||||
module Phaser {
|
||||
class TweenManager {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _tweens;
|
||||
public getAll(): Tween[];
|
||||
public removeAll(): void;
|
||||
public create(object): Tween;
|
||||
public add(tween: Tween): Tween;
|
||||
public remove(tween: Tween): void;
|
||||
public update(): bool;
|
||||
}
|
||||
}
|
||||
Vendored
-32
@@ -1,32 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class World {
|
||||
constructor(game: Game, width: number, height: number);
|
||||
private _game;
|
||||
public cameras: CameraManager;
|
||||
public group: Group;
|
||||
public bounds: Rectangle;
|
||||
public worldDivisions: number;
|
||||
public update(): void;
|
||||
public render(): void;
|
||||
public destroy(): void;
|
||||
public setSize(width: number, height: number, updateCameraBounds?: bool): void;
|
||||
public width : number;
|
||||
public height : number;
|
||||
public centerX : number;
|
||||
public centerY : number;
|
||||
public randomX : number;
|
||||
public randomY : number;
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera;
|
||||
public removeCamera(id: number): bool;
|
||||
public getAllCameras(): Camera[];
|
||||
public createSprite(x: number, y: number, key?: string): Sprite;
|
||||
public createGeomSprite(x: number, y: number): GeomSprite;
|
||||
public createDynamicTexture(width: number, height: number): DynamicTexture;
|
||||
public createGroup(MaxSize?: number): Group;
|
||||
public createScrollZone(key: string, x?: number, y?: number, width?: number, height?: number): ScrollZone;
|
||||
public createTilemap(key: string, mapData: string, format: number, resizeWorld?: bool, tileWidth?: number, tileHeight?: number): Tilemap;
|
||||
public createParticle(): Particle;
|
||||
public createEmitter(x?: number, y?: number, size?: number): Emitter;
|
||||
}
|
||||
}
|
||||
+8
-147
@@ -1,4 +1,7 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="cameras/CameraManager.ts" />
|
||||
/// <reference path="core/Group.ts" />
|
||||
/// <reference path="core/Rectangle.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - World
|
||||
@@ -64,28 +67,15 @@ module Phaser {
|
||||
public worldDivisions: number;
|
||||
|
||||
/**
|
||||
* This is called automatically every frame, and is where main logic performs.
|
||||
* This is called automatically every frame, and is where main logic happens.
|
||||
*/
|
||||
public update() {
|
||||
|
||||
this.group.preUpdate();
|
||||
this.group.update();
|
||||
this.group.postUpdate();
|
||||
|
||||
this.cameras.update();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render every thing to the screen, automatically called after update().
|
||||
*/
|
||||
public render() {
|
||||
|
||||
// Unlike in flixel our render process is camera driven, not group driven
|
||||
this.cameras.render();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
@@ -97,18 +87,14 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
// World methods
|
||||
|
||||
/**
|
||||
* Update size of this world with specific width and height.
|
||||
* You can choose update camera bounds and verlet manager automatically or not.
|
||||
* Updates the size of this world.
|
||||
*
|
||||
* @param width {number} New width of the world.
|
||||
* @param height {number} New height of the world.
|
||||
* @param [updateCameraBounds] {boolean} update camera bounds automatically or not. Default to true.
|
||||
* @param [updateVerletBounds] {boolean} update verlet bounds automatically or not. Default to true.
|
||||
* @param [updateCameraBounds] {boolean} Update camera bounds automatically or not. Default to true.
|
||||
*/
|
||||
public setSize(width: number, height: number, updateCameraBounds: bool = true, updateVerletBounds: bool = true) {
|
||||
public setSize(width: number, height: number, updateCameraBounds: bool = true) {
|
||||
|
||||
this.bounds.width = width;
|
||||
this.bounds.height = height;
|
||||
@@ -118,11 +104,7 @@ module Phaser {
|
||||
this._game.camera.setBounds(0, 0, width, height);
|
||||
}
|
||||
|
||||
if (updateVerletBounds == true)
|
||||
{
|
||||
this._game.verlet.width = width;
|
||||
this._game.verlet.height = height;
|
||||
}
|
||||
// dispatch world resize event
|
||||
|
||||
}
|
||||
|
||||
@@ -158,31 +140,6 @@ module Phaser {
|
||||
return Math.round(Math.random() * this.bounds.height);
|
||||
}
|
||||
|
||||
// Cameras
|
||||
|
||||
/**
|
||||
* Create a new camera with specific position and size.
|
||||
*
|
||||
* @param x {number} X position of the new camera.
|
||||
* @param y {number} Y position of the new camera.
|
||||
* @param width {number} Width of the new camera.
|
||||
* @param height {number} Height of the new camera.
|
||||
* @returns {Camera} The newly created camera object.
|
||||
*/
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
return this.cameras.addCamera(x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a new camera with its id.
|
||||
*
|
||||
* @param id {number} ID of the camera you want to remove.
|
||||
* @returns {boolean} True if successfully removed the camera, otherwise return false.
|
||||
*/
|
||||
public removeCamera(id: number): bool {
|
||||
return this.cameras.removeCamera(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the cameras.
|
||||
*
|
||||
@@ -192,102 +149,6 @@ module Phaser {
|
||||
return this.cameras.getAll();
|
||||
}
|
||||
|
||||
// Game Objects
|
||||
|
||||
/**
|
||||
* Create a new Sprite with specific position and sprite sheet key.
|
||||
*
|
||||
* @param x {number} X position of the new sprite.
|
||||
* @param y {number} Y position of the new sprite.
|
||||
* @param [key] {string} key for the sprite sheet you want it to use.
|
||||
* @returns {Sprite} The newly created sprite object.
|
||||
*/
|
||||
public createSprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
return <Sprite> this.group.add(new Sprite(this._game, x, y, key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new GeomSprite with specific position.
|
||||
*
|
||||
* @param x {number} X position of the new geom sprite.
|
||||
* @param y {number} Y position of the new geom sprite.
|
||||
* @returns {GeomSprite} The newly created geom sprite object.
|
||||
*/
|
||||
public createGeomSprite(x: number, y: number): GeomSprite {
|
||||
return <GeomSprite> this.group.add(new GeomSprite(this._game, x, y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DynamicTexture with specific size.
|
||||
*
|
||||
* @param width {number} Width of the texture.
|
||||
* @param height {number} Height of the texture.
|
||||
* @returns {DynamicTexture} The newly created dynamic texture object.
|
||||
*/
|
||||
public createDynamicTexture(width: number, height: number): DynamicTexture {
|
||||
return new DynamicTexture(this._game, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ScrollZone object with image key, position and size.
|
||||
*
|
||||
* @param key {number} Key to a image you wish this object to use.
|
||||
* @param x {number} X position of this object.
|
||||
* @param y {number} Y position of this object.
|
||||
* @param width {number} Width of this object.
|
||||
* @param height {number} Height of this object.
|
||||
* @returns {ScrollZone} The newly created scroll zone object.
|
||||
*/
|
||||
public createScrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
|
||||
return <ScrollZone> this.group.add(new ScrollZone(this._game, key, x, y, width, height));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Tilemap.
|
||||
*
|
||||
* @param key {string} Key for tileset image.
|
||||
* @param mapData {string} Data of this tilemap.
|
||||
* @param format {number} Format of map data. (Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON)
|
||||
* @param [resizeWorld] {boolean} resize the world to make same as tilemap?
|
||||
* @param [tileWidth] {number} width of each tile.
|
||||
* @param [tileHeight] {number} height of each tile.
|
||||
* @return {Tilemap} The newly created tilemap object.
|
||||
*/
|
||||
public createTilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
|
||||
return <Tilemap> this.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Particle.
|
||||
*
|
||||
* @return {Particle} The newly created particle object.
|
||||
*/
|
||||
public createParticle(): Particle {
|
||||
return new Particle(this._game);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Emitter.
|
||||
*
|
||||
* @param [x] {number} x position of the emitter.
|
||||
* @param [y] {number} y position of the emitter.
|
||||
* @param [size] {number} size of this emitter.
|
||||
* @return {Emitter} The newly created emitter object.
|
||||
*/
|
||||
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
return <Emitter> this.group.add(new Emitter(this._game, x, y, size));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+83
-20
@@ -3,6 +3,7 @@
|
||||
/// <reference path="../core/Vec2.ts" />
|
||||
/// <reference path="../gameobjects/Sprite.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../components/camera/CameraFX.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Camera
|
||||
@@ -17,8 +18,6 @@ module Phaser {
|
||||
export class Camera {
|
||||
|
||||
/**
|
||||
|
||||
*Sprite constructor
|
||||
* Instantiates a new camera at the specified location, with the specified size and zoom level.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
@@ -35,7 +34,9 @@ module Phaser {
|
||||
this.ID = id;
|
||||
this._stageX = x;
|
||||
this._stageY = y;
|
||||
this.fx = new FXManager(this._game, this);
|
||||
this.scaledX = x;
|
||||
this.scaledY = x;
|
||||
this.fx = new CameraFX(this._game, this);
|
||||
|
||||
// The view into the world canvas we wish to render
|
||||
this.worldView = new Rectangle(0, 0, width, height);
|
||||
@@ -54,8 +55,11 @@ module Phaser {
|
||||
private _stageY: number;
|
||||
private _rotation: number = 0;
|
||||
private _target: Sprite = null;
|
||||
private _sx: number = 0;
|
||||
private _sy: number = 0;
|
||||
//private _sx: number = 0;
|
||||
//private _sy: number = 0;
|
||||
|
||||
public scaledX: number;
|
||||
public scaledY: number;
|
||||
|
||||
/**
|
||||
* Camera "follow" style preset: camera has no deadzone, just tracks the focus object directly.
|
||||
@@ -164,9 +168,55 @@ module Phaser {
|
||||
|
||||
/**
|
||||
* Effects manager.
|
||||
* @type {FXManager}
|
||||
* @type {CameraFX}
|
||||
*/
|
||||
public fx: FXManager;
|
||||
public fx: CameraFX;
|
||||
|
||||
/**
|
||||
* Hides an object from this Camera. Hidden objects are not rendered.
|
||||
* The object must implement a public cameraBlacklist property.
|
||||
*
|
||||
* @param object {Sprite/Group} The object this camera should ignore.
|
||||
*/
|
||||
public hide(object) {
|
||||
|
||||
if (this.isHidden(object) == false)
|
||||
{
|
||||
object['cameraBlacklist'].push(this.ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the object is hidden from this Camera.
|
||||
*
|
||||
* @param object {Sprite/Group} The object to check.
|
||||
*/
|
||||
public isHidden(object): bool {
|
||||
|
||||
if (object['cameraBlacklist'] && object['cameraBlacklist'].length > 0 && object['cameraBlacklist'].indexOf(this.ID) == -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Un-hides an object previously hidden to this Camera.
|
||||
* The object must implement a public cameraBlacklist property.
|
||||
*
|
||||
* @param object {Sprite/Group} The object this camera should display.
|
||||
*/
|
||||
public show(object) {
|
||||
|
||||
if (this.isHidden(object) == true)
|
||||
{
|
||||
object['cameraBlacklist'].slice(object['cameraBlacklist'].indexOf(this.ID), 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells this camera object what sprite to track.
|
||||
@@ -339,9 +389,9 @@ module Phaser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw background, shadow, effects, and objects if this is visible.
|
||||
* Camera preRender
|
||||
*/
|
||||
public render() {
|
||||
public preRender() {
|
||||
|
||||
if (this.visible === false || this.alpha < 0.1)
|
||||
{
|
||||
@@ -360,32 +410,32 @@ module Phaser {
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._sx = this._stageX;
|
||||
this._sy = this._stageY;
|
||||
this.scaledX = this._stageX;
|
||||
this.scaledY = this._stageY;
|
||||
|
||||
// Scale on
|
||||
if (this.scale.x !== 1 || this.scale.y !== 1)
|
||||
{
|
||||
this._game.stage.context.scale(this.scale.x, this.scale.y);
|
||||
this._sx = this._sx / this.scale.x;
|
||||
this._sy = this._sy / this.scale.y;
|
||||
this.scaledX = this.scaledX / this.scale.x;
|
||||
this.scaledY = this.scaledY / this.scale.y;
|
||||
}
|
||||
|
||||
// Rotation - translate to the mid-point of the camera
|
||||
if (this._rotation !== 0)
|
||||
{
|
||||
this._game.stage.context.translate(this._sx + this.worldView.halfWidth, this._sy + this.worldView.halfHeight);
|
||||
this._game.stage.context.translate(this.scaledX + this.worldView.halfWidth, this.scaledY + this.worldView.halfHeight);
|
||||
this._game.stage.context.rotate(this._rotation * (Math.PI / 180));
|
||||
|
||||
// now shift back to where that should actually render
|
||||
this._game.stage.context.translate(-(this._sx + this.worldView.halfWidth), -(this._sy + this.worldView.halfHeight));
|
||||
this._game.stage.context.translate(-(this.scaledX + this.worldView.halfWidth), -(this.scaledY + this.worldView.halfHeight));
|
||||
}
|
||||
|
||||
// Background
|
||||
if (this.opaque)
|
||||
{
|
||||
this._game.stage.context.fillStyle = this.backgroundColor;
|
||||
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
this._game.stage.context.fillRect(this.scaledX, this.scaledY, this.worldView.width, this.worldView.height);
|
||||
}
|
||||
|
||||
this.fx.render(this, this._stageX, this._stageY, this.worldView.width, this.worldView.height);
|
||||
@@ -394,13 +444,17 @@ module Phaser {
|
||||
if (this._clip == true && this.disableClipping == false)
|
||||
{
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
this._game.stage.context.rect(this.scaledX, this.scaledY, this.worldView.width, this.worldView.height);
|
||||
this._game.stage.context.closePath();
|
||||
this._game.stage.context.clip();
|
||||
}
|
||||
|
||||
// Render all the Sprites
|
||||
this._game.world.group.render(this, this._sx, this._sy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Camera postRender
|
||||
*/
|
||||
public postRender() {
|
||||
|
||||
// Scale off
|
||||
if (this.scale.x !== 1 || this.scale.y !== 1)
|
||||
@@ -408,7 +462,7 @@ module Phaser {
|
||||
this._game.stage.context.scale(1, 1);
|
||||
}
|
||||
|
||||
this.fx.postRender(this, this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
this.fx.postRender(this, this.scaledX, this.scaledY, this.worldView.width, this.worldView.height);
|
||||
|
||||
if (this._rotation !== 0 || (this._clip && this.disableClipping == false))
|
||||
{
|
||||
@@ -474,6 +528,15 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys this camera, associated FX and removes itself from the CameraManager.
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
this._game.world.cameras.removeCamera(this.ID);
|
||||
this.fx.destroy();
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
return this._stageX;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="system/Camera.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Camera.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - CameraManager
|
||||
@@ -46,6 +46,9 @@ module Phaser {
|
||||
*/
|
||||
private _cameraInstance: number = 0;
|
||||
|
||||
public static CAMERA_TYPE_ORTHOGRAPHIC: number = 0;
|
||||
public static CAMERA_TYPE_ISOMETRIC: number = 1;
|
||||
|
||||
/**
|
||||
* Currently used camera.
|
||||
*/
|
||||
@@ -67,13 +70,6 @@ module Phaser {
|
||||
this._cameras.forEach((camera) => camera.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Render cameras.
|
||||
*/
|
||||
public render() {
|
||||
this._cameras.forEach((camera) => camera.render());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new camera with specific position and size.
|
||||
*
|
||||
@@ -83,7 +79,7 @@ module Phaser {
|
||||
* @param height {number} Height of the new camera.
|
||||
* @returns {Camera} The newly created camera object.
|
||||
*/
|
||||
public addCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
public addCamera(x: number, y: number, width: number, height: number, type: number = CameraManager.CAMERA_TYPE_ORTHOGRAPHIC): Camera {
|
||||
|
||||
var newCam: Camera = new Camera(this._game, this._cameraInstance, x, y, width, height);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../geom/Quad.ts" />
|
||||
/// <reference path="../core/Rectangle.ts" />
|
||||
/// <reference path="../core/Vec2.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - ScrollRegion
|
||||
@@ -26,23 +27,23 @@ module Phaser {
|
||||
constructor(x: number, y: number, width: number, height: number, speedX:number, speedY:number) {
|
||||
|
||||
// Our seamless scrolling quads
|
||||
this._A = new Quad(x, y, width, height);
|
||||
this._B = new Quad(x, y, width, height);
|
||||
this._C = new Quad(x, y, width, height);
|
||||
this._D = new Quad(x, y, width, height);
|
||||
this._scroll = new MicroPoint();
|
||||
this._bounds = new Quad(x, y, width, height);
|
||||
this.scrollSpeed = new MicroPoint(speedX, speedY);
|
||||
this._A = new Rectangle(x, y, width, height);
|
||||
this._B = new Rectangle(x, y, width, height);
|
||||
this._C = new Rectangle(x, y, width, height);
|
||||
this._D = new Rectangle(x, y, width, height);
|
||||
this._scroll = new Vec2();
|
||||
this._bounds = new Rectangle(x, y, width, height);
|
||||
this.scrollSpeed = new Vec2(speedX, speedY);
|
||||
|
||||
}
|
||||
|
||||
private _A: Quad;
|
||||
private _B: Quad;
|
||||
private _C: Quad;
|
||||
private _D: Quad;
|
||||
private _A: Rectangle;
|
||||
private _B: Rectangle;
|
||||
private _C: Rectangle;
|
||||
private _D: Rectangle;
|
||||
|
||||
private _bounds: Quad;
|
||||
private _scroll: MicroPoint;
|
||||
private _bounds: Rectangle;
|
||||
private _scroll: Vec2;
|
||||
|
||||
private _anchorWidth: number = 0;
|
||||
private _anchorHeight: number = 0;
|
||||
@@ -57,9 +58,9 @@ module Phaser {
|
||||
|
||||
/**
|
||||
* Region scrolling speed.
|
||||
* @type {MicroPoint}
|
||||
* @type {Vec2}
|
||||
*/
|
||||
public scrollSpeed: MicroPoint;
|
||||
public scrollSpeed: Vec2;
|
||||
|
||||
/**
|
||||
* Update region scrolling with tick time.
|
||||
@@ -107,20 +108,20 @@ module Phaser {
|
||||
this._inverseWidth = this._bounds.width - this._anchorWidth;
|
||||
this._inverseHeight = this._bounds.height - this._anchorHeight;
|
||||
|
||||
// Quad A
|
||||
// Rectangle A
|
||||
this._A.setTo(this._scroll.x, this._scroll.y, this._anchorWidth, this._anchorHeight);
|
||||
|
||||
// Quad B
|
||||
// Rectangle B
|
||||
this._B.y = this._scroll.y;
|
||||
this._B.width = this._inverseWidth;
|
||||
this._B.height = this._anchorHeight;
|
||||
|
||||
// Quad C
|
||||
// Rectangle C
|
||||
this._C.x = this._scroll.x;
|
||||
this._C.width = this._anchorWidth;
|
||||
this._C.height = this._inverseHeight;
|
||||
|
||||
// Quad D
|
||||
// Rectangle D
|
||||
this._D.width = this._inverseWidth;
|
||||
this._D.height = this._inverseHeight;
|
||||
|
||||
@@ -152,10 +153,10 @@ module Phaser {
|
||||
|
||||
//context.fillStyle = 'rgb(255,255,255)';
|
||||
//context.font = '18px Arial';
|
||||
//context.fillText('QuadA: ' + this._A.toString(), 32, 450);
|
||||
//context.fillText('QuadB: ' + this._B.toString(), 32, 480);
|
||||
//context.fillText('QuadC: ' + this._C.toString(), 32, 510);
|
||||
//context.fillText('QuadD: ' + this._D.toString(), 32, 540);
|
||||
//context.fillText('RectangleA: ' + this._A.toString(), 32, 450);
|
||||
//context.fillText('RectangleB: ' + this._B.toString(), 32, 480);
|
||||
//context.fillText('RectangleC: ' + this._C.toString(), 32, 510);
|
||||
//context.fillText('RectangleD: ' + this._D.toString(), 32, 540);
|
||||
|
||||
}
|
||||
|
||||
@@ -47,11 +47,13 @@ module Phaser {
|
||||
* @type {number}
|
||||
*/
|
||||
public mass: number = 1.0;
|
||||
|
||||
/**
|
||||
* Tile width.
|
||||
* @type {number}
|
||||
*/
|
||||
public width: number;
|
||||
|
||||
/**
|
||||
* Tile height.
|
||||
* @type {number}
|
||||
@@ -69,16 +71,19 @@ module Phaser {
|
||||
* @type {boolean}
|
||||
*/
|
||||
public collideLeft: bool = false;
|
||||
|
||||
/**
|
||||
* Indicating collide with any object on the right.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public collideRight: bool = false;
|
||||
|
||||
/**
|
||||
* Indicating collide with any object on the top.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public collideUp: bool = false;
|
||||
|
||||
/**
|
||||
* Indicating collide with any object on the bottom.
|
||||
* @type {boolean}
|
||||
@@ -90,6 +95,7 @@ module Phaser {
|
||||
* @type {boolean}
|
||||
*/
|
||||
public separateX: bool = true;
|
||||
|
||||
/**
|
||||
* Enable separation at y-axis.
|
||||
* @type {boolean}
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="gameobjects/Sprite.ts" />
|
||||
/// <reference path="system/animation/Animation.ts" />
|
||||
/// <reference path="system/animation/AnimationLoader.ts" />
|
||||
/// <reference path="system/animation/Frame.ts" />
|
||||
/// <reference path="system/animation/FrameData.ts" />
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../gameobjects/Sprite.ts" />
|
||||
/// <reference path="../../loader/AnimationLoader.ts" />
|
||||
/// <reference path="Animation.ts" />
|
||||
/// <reference path="Frame.ts" />
|
||||
/// <reference path="FrameData.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - AnimationManager
|
||||
@@ -1,14 +1,15 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../cameras/Camera.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FXManager
|
||||
* Phaser - CameraFX
|
||||
*
|
||||
* The FXManager controls all special effects applied to game objects such as Cameras.
|
||||
* CameraFX controls all special effects applied to game Cameras.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class FXManager {
|
||||
export class CameraFX {
|
||||
|
||||
constructor(game: Game, parent) {
|
||||
|
||||
@@ -69,7 +70,7 @@ module Phaser {
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Error("Invalid object given to Phaser.FXManager.add");
|
||||
throw new Error("Invalid object given to Phaser.CameraFX.add");
|
||||
}
|
||||
|
||||
// Check for methods now to avoid having to do this every loop
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Phaser - Components - Debug
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
module Phaser.Components {
|
||||
|
||||
export class Debug {
|
||||
|
||||
/**
|
||||
* Render bound of this sprite for debugging? (default to false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public renderDebug: bool = false;
|
||||
|
||||
/**
|
||||
* Color of the Sprite when no image is present. Format is a css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public fillColor: string = 'rgb(255,255,255)';
|
||||
|
||||
/**
|
||||
* Color of bound when render debug. (see renderDebug) Format is a css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public renderDebugColor: string = 'rgba(0,255,0,0.5)';
|
||||
|
||||
/**
|
||||
* Color of points when render debug. (see renderDebug) Format is a css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public renderDebugPointColor: string = 'rgba(255,255,255,1)';
|
||||
|
||||
/**
|
||||
* Renders the bounding box around this Sprite and the contact points. Useful for visually debugging.
|
||||
* @param camera {Camera} Camera the bound will be rendered to.
|
||||
* @param cameraOffsetX {number} X offset of bound to the camera.
|
||||
* @param cameraOffsetY {number} Y offset of bound to the camera.
|
||||
*/
|
||||
/*
|
||||
private renderBounds(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
|
||||
|
||||
this._dx = cameraOffsetX + (this.frameBounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.frameBounds.topLeft.y - camera.worldView.y);
|
||||
|
||||
this.context.fillStyle = this.renderDebugColor;
|
||||
this.context.fillRect(this._dx, this._dy, this.frameBounds.width, this.frameBounds.height);
|
||||
|
||||
//this.context.fillStyle = this.renderDebugPointColor;
|
||||
|
||||
//var hw = this.frameBounds.halfWidth * this.scale.x;
|
||||
//var hh = this.frameBounds.halfHeight * this.scale.y;
|
||||
//var sw = (this.frameBounds.width * this.scale.x) - 1;
|
||||
//var sh = (this.frameBounds.height * this.scale.y) - 1;
|
||||
|
||||
//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
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Render debug infos. (including name, bounds info, position and some other properties)
|
||||
* @param x {number} X position of the debug info to be rendered.
|
||||
* @param y {number} Y position of the debug info to be rendered.
|
||||
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
|
||||
*/
|
||||
/*
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillText('Sprite: ' + this.name + ' (' + this.frameBounds.width + ' x ' + this.frameBounds.height + ')', x, y);
|
||||
this.context.fillText('x: ' + this.frameBounds.x.toFixed(1) + ' y: ' + this.frameBounds.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);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Phaser - Components - Input
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
module Phaser.Components {
|
||||
|
||||
export class Input {
|
||||
|
||||
// Input
|
||||
//public inputEnabled: bool = false;
|
||||
//private _inputOver: bool = false;
|
||||
|
||||
//public onInputOver: Phaser.Signal;
|
||||
//public onInputOut: Phaser.Signal;
|
||||
//public onInputDown: Phaser.Signal;
|
||||
//public onInputUp: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* Update input.
|
||||
*/
|
||||
private updateInput() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/// <reference path="../../core/Vec2.ts" />
|
||||
/// <reference path="../../core/Point.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Components - Physics
|
||||
*
|
||||
@@ -22,9 +25,9 @@ module Phaser.Components {
|
||||
* accurate due to the way timers work, but it's pretty close. Expect tolerance
|
||||
* of +- 10 px. Also that speed assumes no drag.
|
||||
*
|
||||
* @type {MicroPoint}
|
||||
* @type {Vec2}
|
||||
*/
|
||||
public velocity: MicroPoint;
|
||||
public velocity: Vec2;
|
||||
|
||||
/**
|
||||
* The virtual mass of the object.
|
||||
@@ -42,21 +45,21 @@ module Phaser.Components {
|
||||
* How fast the speed of this object is changing.
|
||||
* @type {number}
|
||||
*/
|
||||
public acceleration: MicroPoint;
|
||||
public acceleration: Vec2;
|
||||
|
||||
/**
|
||||
* This isn't drag exactly, more like deceleration that is only applied
|
||||
* when acceleration is not affecting the sprite.
|
||||
* @type {MicroPoint}
|
||||
* @type {Vec2}
|
||||
*/
|
||||
public drag: MicroPoint;
|
||||
public drag: Vec2;
|
||||
|
||||
/**
|
||||
* It will cap the speed automatically if you use the acceleration
|
||||
* to change its velocity.
|
||||
* @type {MicroPoint}
|
||||
* @type {Vec2}
|
||||
*/
|
||||
public maxVelocity: MicroPoint;
|
||||
public maxVelocity: Vec2;
|
||||
|
||||
/**
|
||||
* How fast this object is rotating.
|
||||
@@ -110,15 +113,41 @@ module Phaser.Components {
|
||||
|
||||
/**
|
||||
* Important variable for collision processing.
|
||||
* @type {MicroPoint}
|
||||
* @type {Vec2}
|
||||
*/
|
||||
public last: MicroPoint;
|
||||
public last: Vec2;
|
||||
|
||||
/**
|
||||
* Handy for checking if this object is touching a particular surface.
|
||||
* For slightly better performance you can just & the value directly into <code>touching</code>.
|
||||
* However, this method is good for readability and accessibility.
|
||||
*
|
||||
* @param Direction {number} Any of the collision flags (e.g. LEFT, FLOOR, etc).
|
||||
*
|
||||
* @return {boolean} Whether the object is touching an object in (any of) the specified direction(s) this frame.
|
||||
*/
|
||||
public isTouching(direction: number): bool {
|
||||
return (this.touching & direction) > Collision.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy function for checking if this object just landed on a particular surface.
|
||||
*
|
||||
* @param Direction {number} Any of the collision flags (e.g. LEFT, FLOOR, etc).
|
||||
*
|
||||
* @returns {boolean} Whether the object just landed on any specicied surfaces.
|
||||
*/
|
||||
public justTouched(direction: number): bool {
|
||||
return ((this.touching & direction) > Collision.NONE) && ((this.wasTouching & direction) <= Collision.NONE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Internal function for updating the position and speed of this object.
|
||||
*/
|
||||
public update() {
|
||||
|
||||
/*
|
||||
var delta: number;
|
||||
var velocityDelta: number;
|
||||
|
||||
@@ -138,9 +167,31 @@ module Phaser.Components {
|
||||
delta = this.velocity.y * this._game.time.elapsed;
|
||||
this.velocity.y += velocityDelta;
|
||||
this.frameBounds.y += delta;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the object collides or not. For more control over what directions
|
||||
* the object will collide from, use collision constants (like LEFT, FLOOR, etc)
|
||||
* to set the value of allowCollisions directly.
|
||||
*/
|
||||
public get solid(): bool {
|
||||
return (this.allowCollisions & Collision.ANY) > Collision.NONE;
|
||||
}
|
||||
|
||||
public set solid(value: bool) {
|
||||
|
||||
if (value)
|
||||
{
|
||||
this.allowCollisions = Collision.ANY;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowCollisions = Collision.NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/// <reference path="../../core/Vec2.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Components - Position
|
||||
*
|
||||
* Sprite position, both world and screen, and rotation values and methods.
|
||||
*/
|
||||
|
||||
module Phaser.Components {
|
||||
|
||||
export class Position {
|
||||
|
||||
constructor(parent: Sprite, x: number, y: number) {
|
||||
|
||||
this._sprite = parent;
|
||||
|
||||
this.world = new Phaser.Vec2(x, y);
|
||||
this.screen = new Phaser.Vec2(x, y);
|
||||
|
||||
this.offset = new Phaser.Vec2(0, 0);
|
||||
this.midpoint = new Phaser.Vec2(0, 0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reference to the Image stored in the Game.Cache that is used as the texture for the Sprite.
|
||||
*/
|
||||
private _sprite: Sprite;
|
||||
|
||||
public world: Phaser.Vec2;
|
||||
public screen: Phaser.Vec2;
|
||||
|
||||
public offset: Phaser.Vec2;
|
||||
public midpoint: Phaser.Vec2;
|
||||
|
||||
/**
|
||||
* Rotation angle of this object.
|
||||
* @type {number}
|
||||
*/
|
||||
private _rotation: number = 0;
|
||||
|
||||
/**
|
||||
* Z-order value of the object.
|
||||
*/
|
||||
public z: number = 0;
|
||||
|
||||
/**
|
||||
* This value is added to the rotation of the Sprite.
|
||||
* For example if you had a sprite graphic drawn facing straight up then you could set
|
||||
* rotationOffset to 90 and it would correspond correctly with Phasers right-handed coordinate system.
|
||||
* @type {number}
|
||||
*/
|
||||
public rotationOffset: number = 0;
|
||||
|
||||
public get rotation(): number {
|
||||
return this._rotation;
|
||||
}
|
||||
|
||||
public set rotation(value: number) {
|
||||
this._rotation = this._sprite.game.math.wrap(value, 360, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Phaser - Components - Properties
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
module Phaser.Components {
|
||||
|
||||
export class Properties {
|
||||
|
||||
/**
|
||||
* Handy for storing health percentage or armor points or whatever.
|
||||
* @type {number}
|
||||
*/
|
||||
public health: number;
|
||||
|
||||
/**
|
||||
* Reduces the "health" variable of this sprite by the amount specified in Damage.
|
||||
* Calls kill() if health drops to or below zero.
|
||||
*
|
||||
* @param Damage {number} How much health to take away (use a negative number to give a health bonus).
|
||||
*/
|
||||
public hurt(damage: number) {
|
||||
|
||||
this.health = this.health - damage;
|
||||
|
||||
if (this.health <= 0)
|
||||
{
|
||||
//this.kill();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,171 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../gameobjects/DynamicTexture.ts" />
|
||||
/// <reference path="../../utils/SpriteUtils.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Components - Texture
|
||||
*
|
||||
* The Sprite GameObject is an extension of the core GameObject that includes support for animation and dynamic textures.
|
||||
* The Texture being used to render the Sprite. Either Image based on a DynamicTexture.
|
||||
*/
|
||||
|
||||
module Phaser.Components {
|
||||
|
||||
export class Texture {
|
||||
|
||||
constructor(parent: Sprite, key?: string = '', canvas?: HTMLCanvasElement = null, context?: CanvasRenderingContext2D = null) {
|
||||
|
||||
this._sprite = parent;
|
||||
|
||||
this.canvas = canvas;
|
||||
this.context = context;
|
||||
this.alpha = 1;
|
||||
this.flippedX = false;
|
||||
this.flippedY = false;
|
||||
|
||||
if (key !== null)
|
||||
{
|
||||
this.cacheKey = key;
|
||||
this.loadImage(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reference to the Image stored in the Game.Cache that is used as the texture for the Sprite.
|
||||
*/
|
||||
private _sprite: Sprite;
|
||||
|
||||
/**
|
||||
* Reference to the Image stored in the Game.Cache that is used as the texture for the Sprite.
|
||||
*/
|
||||
private _imageTexture = null;
|
||||
|
||||
/**
|
||||
* Reference to the DynamicTexture that is used as the texture for the Sprite.
|
||||
* @type {DynamicTexture}
|
||||
*/
|
||||
private _dynamicTexture: DynamicTexture = null;
|
||||
|
||||
/**
|
||||
* Opacity of the Sprite texture where 1 is opaque and 0 is fully transparent.
|
||||
* @type {number}
|
||||
*/
|
||||
public alpha: number;
|
||||
|
||||
/**
|
||||
* A reference to the Canvas this Sprite renders to.
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
public canvas: HTMLCanvasElement;
|
||||
|
||||
/**
|
||||
* A reference to the Canvas Context2D this Sprite renders to.
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
public context: CanvasRenderingContext2D;
|
||||
|
||||
/**
|
||||
* The Cache key used for the Image Texture.
|
||||
*/
|
||||
public cacheKey: string;
|
||||
|
||||
/**
|
||||
* The Texture being used to render the Sprite. Either an Image Texture from the Cache or a DynamicTexture.
|
||||
*/
|
||||
public texture;
|
||||
|
||||
/**
|
||||
* Controls if the Sprite is rendered rotated or not.
|
||||
* If renderRotation is false then the object can still rotate but it will never be rendered rotated.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public renderRotation: bool = true;
|
||||
|
||||
/**
|
||||
* Flip the graphic horizontally (defaults to false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public flippedX: bool = false;
|
||||
|
||||
/**
|
||||
* Flip the graphic vertically (defaults to false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public flippedY: bool = false;
|
||||
|
||||
/**
|
||||
* Updates the texture being used to render the Sprite.
|
||||
* Called automatically by SpriteUtils.loadTexture and SpriteUtils.loadDynamicTexture.
|
||||
*/
|
||||
public setTo(image = null, dynamic?: DynamicTexture = null): Sprite {
|
||||
|
||||
if (dynamic)
|
||||
{
|
||||
this._dynamicTexture = dynamic;
|
||||
this.texture = this._dynamicTexture.canvas;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._imageTexture = image;
|
||||
this.texture = this._imageTexture;
|
||||
}
|
||||
|
||||
return this._sprite;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new graphic from the game cache to use as the texture for this Sprite.
|
||||
* The graphic can be SpriteSheet or Texture Atlas. If you need to use a DynamicTexture see loadDynamicTexture.
|
||||
* @param key {string} Key of the graphic you want to load for this sprite.
|
||||
* @param clearAnimations {boolean} If this Sprite has a set of animation data already loaded you can choose to keep or clear it with this boolean
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
*/
|
||||
public loadImage(key: string, clearAnimations: bool = true): Sprite {
|
||||
return Phaser.SpriteUtils.loadTexture(this._sprite, key, clearAnimations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a DynamicTexture as its texture.
|
||||
* @param texture {DynamicTexture} The texture object to be used by this sprite.
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
*/
|
||||
public loadDynamicTexture(texture: DynamicTexture): Sprite {
|
||||
return Phaser.SpriteUtils.loadDynamicTexture(this._sprite, texture);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter only. The width of the texture.
|
||||
* @type {number}
|
||||
*/
|
||||
public get width(): number {
|
||||
|
||||
if (this._dynamicTexture)
|
||||
{
|
||||
return this._dynamicTexture.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this._imageTexture.width;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter only. The height of the texture.
|
||||
* @type {number}
|
||||
*/
|
||||
public get height(): number {
|
||||
|
||||
if (this._dynamicTexture)
|
||||
{
|
||||
return this._dynamicTexture.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this._imageTexture.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -27,7 +27,7 @@ module Phaser {
|
||||
|
||||
private _diameter: number = 0;
|
||||
private _radius: number = 0;
|
||||
private _pos: Vector2;
|
||||
//private _pos: Vec2;
|
||||
|
||||
/**
|
||||
* The x coordinate of the center of the circle
|
||||
@@ -249,6 +249,16 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the x, y and diameter properties from any given object to this Circle.
|
||||
* @method copyFrom
|
||||
* @param {any} source - The object to copy from.
|
||||
* @return {Circle} This Circle object.
|
||||
**/
|
||||
public copyFrom(source: any): Circle {
|
||||
return this.setTo(source.x, source.y, source.diameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not this Circle object is empty.
|
||||
* @method empty
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="Basic.ts" />
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../Statics.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Group
|
||||
@@ -9,18 +9,22 @@
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Group extends Basic {
|
||||
export class Group {
|
||||
|
||||
constructor(game: Game, MaxSize?: number = 0) {
|
||||
constructor(game: Game, maxSize?: number = 0) {
|
||||
|
||||
super(game);
|
||||
this.game = game;
|
||||
this.type = Phaser.Types.GROUP;
|
||||
this.exists = true;
|
||||
this.visible = true;
|
||||
|
||||
this.isGroup = true;
|
||||
this.members = [];
|
||||
this.length = 0;
|
||||
this._maxSize = MaxSize;
|
||||
|
||||
this._maxSize = maxSize;
|
||||
this._marker = 0;
|
||||
this._sortIndex = null;
|
||||
|
||||
this.cameraBlacklist = [];
|
||||
|
||||
}
|
||||
@@ -46,6 +50,35 @@ module Phaser {
|
||||
*/
|
||||
private _sortOrder: number;
|
||||
|
||||
/**
|
||||
* Temp vars to help avoid gc spikes
|
||||
*/
|
||||
private _member;
|
||||
private _length: number;
|
||||
private _i: number;
|
||||
private _prevAlpha: number;
|
||||
private _count: number;
|
||||
|
||||
/**
|
||||
* Reference to the main game object
|
||||
*/
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* The type of game object.
|
||||
*/
|
||||
public type: number;
|
||||
|
||||
/**
|
||||
* If this Group exists or not. Can be set to false to skip certain loop checks.
|
||||
*/
|
||||
public exists: bool;
|
||||
|
||||
/**
|
||||
* Controls if this Group (and all of its contents) are rendered or skipped during the core game loop.
|
||||
*/
|
||||
public visible: bool;
|
||||
|
||||
/**
|
||||
* Use with <code>sort()</code> to sort in ascending order.
|
||||
*/
|
||||
@@ -57,9 +90,9 @@ module Phaser {
|
||||
public static DESCENDING: number = 1;
|
||||
|
||||
/**
|
||||
* Array of all the <code>Basic</code>s that exist in this group.
|
||||
* Array of all the objects that exist in this group.
|
||||
*/
|
||||
public members: Basic[];
|
||||
public members;
|
||||
|
||||
/**
|
||||
* The number of entries in the members array.
|
||||
@@ -89,43 +122,6 @@ module Phaser {
|
||||
*/
|
||||
public cameraBlacklist: number[];
|
||||
|
||||
/**
|
||||
* If you do not wish this object to be visible to a specific camera, pass the camera here.
|
||||
*
|
||||
* @param camera {Camera} The specific camera.
|
||||
*/
|
||||
public hideFromCamera(camera: Camera) {
|
||||
|
||||
if (this.cameraBlacklist.indexOf(camera.ID) == -1)
|
||||
{
|
||||
this.cameraBlacklist.push(camera.ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Make this object only visible to a specific camera.
|
||||
*
|
||||
* @param camera {Camera} The camera you wish it to be visible.
|
||||
*/
|
||||
public showToCamera(camera: Camera) {
|
||||
|
||||
if (this.cameraBlacklist.indexOf(camera.ID) !== -1)
|
||||
{
|
||||
this.cameraBlacklist.slice(this.cameraBlacklist.indexOf(camera.ID), 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This clears the camera black list, making the GameObject visible to all cameras.
|
||||
*/
|
||||
public clearCameraList() {
|
||||
|
||||
this.cameraBlacklist.length = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this function to handle any deleting or "shutdown" type operations you might need,
|
||||
* such as removing traditional Flash children like Basic objects.
|
||||
@@ -134,16 +130,15 @@ module Phaser {
|
||||
|
||||
if (this.members != null)
|
||||
{
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if (basic != null)
|
||||
if (this._member != null)
|
||||
{
|
||||
basic.destroy();
|
||||
this._member.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,79 +150,69 @@ module Phaser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically goes through and calls update on everything you added.
|
||||
*/
|
||||
* Calls update on all members of this Group who have a status of active=true and exists=true
|
||||
* You can also call Object.update directly, which will bypass the active/exists check.
|
||||
*/
|
||||
public update(forceUpdate?: bool = false) {
|
||||
|
||||
if (this.ignoreGlobalUpdate && forceUpdate == false)
|
||||
this._i = 0;
|
||||
|
||||
while (this._i < this.length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.active && basic.ignoreGlobalUpdate == false)
|
||||
if (this._member != null && this._member.exists && this._member.active)
|
||||
{
|
||||
basic.preUpdate();
|
||||
basic.update(forceUpdate);
|
||||
basic.postUpdate();
|
||||
this._member.preUpdate();
|
||||
this._member.update(forceUpdate);
|
||||
this._member.postUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically goes through and calls render on everything you added.
|
||||
*/
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number, forceRender?: bool = false) {
|
||||
* Calls render on all members of this Group who have a status of visible=true and exists=true
|
||||
* You can also call Object.render directly, which will bypass the visible/exists check.
|
||||
*/
|
||||
public render(camera: Camera) {
|
||||
|
||||
if (this.cameraBlacklist.indexOf(camera.ID) !== -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.ignoreGlobalRender && forceRender == false)
|
||||
if (camera.isHidden(this) == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.globalCompositeOperation)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.globalCompositeOperation = this.globalCompositeOperation;
|
||||
this.game.stage.context.save();
|
||||
this.game.stage.context.globalCompositeOperation = this.globalCompositeOperation;
|
||||
}
|
||||
|
||||
if (this.alpha > 0)
|
||||
{
|
||||
var prevAlpha: number = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
this._prevAlpha = this.game.stage.context.globalAlpha;
|
||||
this.game.stage.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.visible && basic.ignoreGlobalRender == false)
|
||||
if (this._member != null && this._member.exists && this._member.visible && camera.isHidden(this._member) == false)
|
||||
{
|
||||
basic.render(camera, cameraOffsetX, cameraOffsetY, forceRender);
|
||||
this._member.render(camera, this._member);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.alpha > 0)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = prevAlpha;
|
||||
this.game.stage.context.globalAlpha = this._prevAlpha;
|
||||
}
|
||||
|
||||
if (this.globalCompositeOperation)
|
||||
{
|
||||
this._game.stage.context.restore();
|
||||
this.game.stage.context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,23 +235,22 @@ module Phaser {
|
||||
this._marker = 0;
|
||||
}
|
||||
|
||||
if ((this._maxSize == 0) || (this.members == null) || (this._maxSize >= this.members.length))
|
||||
if (this._maxSize == 0 || this.members == null || (this._maxSize >= this.members.length))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//If the max size has shrunk, we need to get rid of some objects
|
||||
var basic: Basic;
|
||||
var i: number = this._maxSize;
|
||||
var l: number = this.members.length;
|
||||
this._i = this._maxSize;
|
||||
this._length = this.members.length;
|
||||
|
||||
while (i < l)
|
||||
while (this._i < this._length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if (basic != null)
|
||||
if (this._member != null)
|
||||
{
|
||||
basic.destroy();
|
||||
this._member.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,33 +269,33 @@ 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): any {
|
||||
public add(object): any {
|
||||
|
||||
//Don't bother adding an object twice.
|
||||
if (this.members.indexOf(Object) >= 0)
|
||||
{
|
||||
return Object;
|
||||
return object;
|
||||
}
|
||||
|
||||
//First, look for a null entry where we can add the object.
|
||||
var i: number = 0;
|
||||
var l: number = this.members.length;
|
||||
this._i = 0;
|
||||
this._length = this.members.length;
|
||||
|
||||
while (i < l)
|
||||
while (this._i < this._length)
|
||||
{
|
||||
if (this.members[i] == null)
|
||||
if (this.members[this._i] == null)
|
||||
{
|
||||
this.members[i] = Object;
|
||||
this.members[this._i] = object;
|
||||
|
||||
if (i >= this.length)
|
||||
if (this._i >= this.length)
|
||||
{
|
||||
this.length = i + 1;
|
||||
this.length = this._i + 1;
|
||||
}
|
||||
|
||||
return Object;
|
||||
return object;
|
||||
}
|
||||
|
||||
i++;
|
||||
this._i++;
|
||||
}
|
||||
|
||||
//Failing that, expand the array (if we can) and add the object.
|
||||
@@ -319,7 +303,7 @@ module Phaser {
|
||||
{
|
||||
if (this.members.length >= this._maxSize)
|
||||
{
|
||||
return Object;
|
||||
return object;
|
||||
}
|
||||
else if (this.members.length * 2 <= this._maxSize)
|
||||
{
|
||||
@@ -337,10 +321,10 @@ module Phaser {
|
||||
|
||||
//If we made it this far, then we successfully grew the group,
|
||||
//and we can go ahead and add the object at the first open slot.
|
||||
this.members[i] = Object;
|
||||
this.length = i + 1;
|
||||
this.members[this._i] = object;
|
||||
this.length = this._i + 1;
|
||||
|
||||
return Object;
|
||||
return object;
|
||||
|
||||
}
|
||||
|
||||
@@ -367,48 +351,46 @@ module Phaser {
|
||||
*
|
||||
* @return {any} A reference to the object that was created. Don't forget to cast it back to the Class you want (e.g. myObject = myGroup.recycle(myObjectClass) as myObjectClass;).
|
||||
*/
|
||||
public recycle(ObjectClass = null) {
|
||||
|
||||
var basic;
|
||||
public recycle(objectClass = null) {
|
||||
|
||||
if (this._maxSize > 0)
|
||||
{
|
||||
if (this.length < this._maxSize)
|
||||
{
|
||||
if (ObjectClass == null)
|
||||
if (objectClass == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.add(new ObjectClass(this._game));
|
||||
return this.add(new objectClass(this.game));
|
||||
}
|
||||
else
|
||||
{
|
||||
basic = this.members[this._marker++];
|
||||
this._member = this.members[this._marker++];
|
||||
|
||||
if (this._marker >= this._maxSize)
|
||||
{
|
||||
this._marker = 0;
|
||||
}
|
||||
|
||||
return basic;
|
||||
return this._member;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
basic = this.getFirstAvailable(ObjectClass);
|
||||
this._member = this.getFirstAvailable(objectClass);
|
||||
|
||||
if (basic != null)
|
||||
if (this._member != null)
|
||||
{
|
||||
return basic;
|
||||
return this._member;
|
||||
}
|
||||
|
||||
if (ObjectClass == null)
|
||||
if (objectClass == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.add(new ObjectClass(this._game));
|
||||
return this.add(new objectClass(this.game));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,23 +402,23 @@ module Phaser {
|
||||
*
|
||||
* @return {Basic} The removed object.
|
||||
*/
|
||||
public remove(object: Basic, splice: bool = false): Basic {
|
||||
public remove(object, splice: bool = false) {
|
||||
|
||||
var index: number = this.members.indexOf(object);
|
||||
this._i = this.members.indexOf(object);
|
||||
|
||||
if ((index < 0) || (index >= this.members.length))
|
||||
if (this._i < 0 || (this._i >= this.members.length))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (splice)
|
||||
{
|
||||
this.members.splice(index, 1);
|
||||
this.members.splice(this._i, 1);
|
||||
this.length--;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.members[index] = null;
|
||||
this.members[this._i] = null;
|
||||
}
|
||||
|
||||
return object;
|
||||
@@ -451,16 +433,16 @@ module Phaser {
|
||||
*
|
||||
* @return {Basic} The new object.
|
||||
*/
|
||||
public replace(oldObject: Basic, newObject: Basic): Basic {
|
||||
public replace(oldObject, newObject) {
|
||||
|
||||
var index: number = this.members.indexOf(oldObject);
|
||||
this._i = this.members.indexOf(oldObject);
|
||||
|
||||
if ((index < 0) || (index >= this.members.length))
|
||||
if (this._i < 0 || (this._i >= this.members.length))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
this.members[index] = newObject;
|
||||
this.members[this._i] = newObject;
|
||||
|
||||
return newObject;
|
||||
|
||||
@@ -491,24 +473,23 @@ module Phaser {
|
||||
* @param {Object} Value The value you want to assign to that variable.
|
||||
* @param {boolean} Recurse Default value is true, meaning if <code>setAll()</code> encounters a member that is a group, it will call <code>setAll()</code> on that group rather than modifying its variable.
|
||||
*/
|
||||
public setAll(VariableName: string, Value: Object, Recurse: bool = true) {
|
||||
public setAll(variableName: string, value: Object, recurse: bool = true) {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if (basic != null)
|
||||
if (this._member != null)
|
||||
{
|
||||
if (Recurse && (basic.isGroup == true))
|
||||
if (recurse && this._member.type == Phaser.Types.GROUP)
|
||||
{
|
||||
<Group> basic['setAll'](VariableName, Value, Recurse);
|
||||
this._member.setAll(variableName, value, recurse);
|
||||
}
|
||||
else
|
||||
{
|
||||
basic[VariableName] = Value;
|
||||
this._member[variableName] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -521,24 +502,23 @@ module Phaser {
|
||||
* @param {string} FunctionName The string representation of the function you want to call on each object, for example "kill()" or "init()".
|
||||
* @param {boolean} Recurse Default value is true, meaning if <code>callAll()</code> encounters a member that is a group, it will call <code>callAll()</code> on that group rather than calling the group's function.
|
||||
*/
|
||||
public callAll(FunctionName: string, Recurse: bool = true) {
|
||||
public callAll(functionName: string, recurse: bool = true) {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if (basic != null)
|
||||
if (this._member != null)
|
||||
{
|
||||
if (Recurse && (basic.isGroup == true))
|
||||
if (recurse && this._member.type == Phaser.Types.GROUP)
|
||||
{
|
||||
<Group> basic['callAll'](FunctionName, Recurse);
|
||||
this._member.callAll(functionName, recurse);
|
||||
}
|
||||
else
|
||||
{
|
||||
basic[FunctionName]();
|
||||
this._member[functionName]();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -550,22 +530,21 @@ module Phaser {
|
||||
*/
|
||||
public forEach(callback, recursive: bool = false) {
|
||||
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if (basic != null)
|
||||
if (this._member != null)
|
||||
{
|
||||
if (recursive && (basic.isGroup == true))
|
||||
if (recursive && this._member.type == Phaser.Types.GROUP)
|
||||
{
|
||||
basic.forEach(callback, true);
|
||||
this._member.forEach(callback, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.call(this, basic);
|
||||
callback.call(this, this._member);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -579,22 +558,21 @@ module Phaser {
|
||||
*/
|
||||
public forEachAlive(context, callback, recursive: bool = false) {
|
||||
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if (basic != null && basic.alive)
|
||||
if (this._member != null && this._member.alive)
|
||||
{
|
||||
if (recursive && (basic.isGroup == true))
|
||||
if (recursive && this._member.type == Phaser.Types.GROUP)
|
||||
{
|
||||
basic.forEachAlive(context, callback, true);
|
||||
this._member.forEachAlive(context, callback, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.call(context, basic);
|
||||
callback.call(context, this._member);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -609,18 +587,17 @@ module Phaser {
|
||||
*
|
||||
* @return {any} A <code>Basic</code> currently flagged as not existing.
|
||||
*/
|
||||
public getFirstAvailable(ObjectClass = null) {
|
||||
public getFirstAvailable(objectClass = null) {
|
||||
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if ((basic != null) && !basic.exists && ((ObjectClass == null) || (typeof basic === ObjectClass)))
|
||||
if ((this._member != null) && !this._member.exists && ((objectClass == null) || (typeof this._member === objectClass)))
|
||||
{
|
||||
return basic;
|
||||
return this._member;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -636,19 +613,17 @@ module Phaser {
|
||||
*/
|
||||
public getFirstNull(): number {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
var l: number = this.members.length;
|
||||
this._i = 0;
|
||||
|
||||
while (i < l)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
if (this.members[i] == null)
|
||||
if (this.members[this._i] == null)
|
||||
{
|
||||
return i;
|
||||
return this._i;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
this._i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,18 +637,17 @@ module Phaser {
|
||||
*
|
||||
* @return {Basic} A <code>Basic</code> currently flagged as existing.
|
||||
*/
|
||||
public getFirstExtant(): Basic {
|
||||
public getFirstExtant() {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if ((basic != null) && basic.exists)
|
||||
if (this._member != null && this._member.exists)
|
||||
{
|
||||
return basic;
|
||||
return this._member;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,18 +661,17 @@ module Phaser {
|
||||
*
|
||||
* @return {Basic} A <code>Basic</code> currently flagged as not dead.
|
||||
*/
|
||||
public getFirstAlive(): Basic {
|
||||
public getFirstAlive() {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.alive)
|
||||
if ((this._member != null) && this._member.exists && this._member.alive)
|
||||
{
|
||||
return basic;
|
||||
return this._member;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -712,18 +685,17 @@ module Phaser {
|
||||
*
|
||||
* @return {Basic} A <code>Basic</code> currently flagged as dead.
|
||||
*/
|
||||
public getFirstDead(): Basic {
|
||||
public getFirstDead() {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if ((basic != null) && !basic.alive)
|
||||
if ((this._member != null) && !this._member.alive)
|
||||
{
|
||||
return basic;
|
||||
return this._member;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,29 +710,28 @@ module Phaser {
|
||||
*/
|
||||
public countLiving(): number {
|
||||
|
||||
var count: number = -1;
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
this._count = -1;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if (basic != null)
|
||||
if (this._member != null)
|
||||
{
|
||||
if (count < 0)
|
||||
if (this._count < 0)
|
||||
{
|
||||
count = 0;
|
||||
this._count = 0;
|
||||
}
|
||||
|
||||
if (basic.exists && basic.alive)
|
||||
if (this._member.exists && this._member.alive)
|
||||
{
|
||||
count++;
|
||||
this._count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
return this._count;
|
||||
|
||||
}
|
||||
|
||||
@@ -771,29 +742,28 @@ module Phaser {
|
||||
*/
|
||||
public countDead(): number {
|
||||
|
||||
var count: number = -1;
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
this._count = -1;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if (basic != null)
|
||||
if (this._member != null)
|
||||
{
|
||||
if (count < 0)
|
||||
if (this._count < 0)
|
||||
{
|
||||
count = 0;
|
||||
this._count = 0;
|
||||
}
|
||||
|
||||
if (!basic.alive)
|
||||
if (!this._member.alive)
|
||||
{
|
||||
count++;
|
||||
this._count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
return this._count;
|
||||
|
||||
}
|
||||
|
||||
@@ -805,14 +775,14 @@ module Phaser {
|
||||
*
|
||||
* @return {Basic} A <code>Basic</code> from the members list.
|
||||
*/
|
||||
public getRandom(StartIndex: number = 0, Length: number = 0): Basic {
|
||||
public getRandom(startIndex: number = 0, length: number = 0) {
|
||||
|
||||
if (Length == 0)
|
||||
if (length == 0)
|
||||
{
|
||||
Length = this.length;
|
||||
length = this.length;
|
||||
}
|
||||
|
||||
return this._game.math.getRandom(this.members, StartIndex, Length);
|
||||
return this.game.math.getRandom(this.members, startIndex, length);
|
||||
|
||||
}
|
||||
|
||||
@@ -829,16 +799,15 @@ module Phaser {
|
||||
*/
|
||||
public kill() {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
this._i = 0;
|
||||
|
||||
while (i < this.length)
|
||||
while (this._i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
this._member = this.members[this._i++];
|
||||
|
||||
if ((basic != null) && basic.exists)
|
||||
if ((this._member != null) && this._member.exists)
|
||||
{
|
||||
basic.kill();
|
||||
this._member.kill();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -852,13 +821,13 @@ module Phaser {
|
||||
*
|
||||
* @return {number} An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2).
|
||||
*/
|
||||
public sortHandler(Obj1: Basic, Obj2: Basic): number {
|
||||
public sortHandler(obj1, obj2): number {
|
||||
|
||||
if (Obj1[this._sortIndex] < Obj2[this._sortIndex])
|
||||
if (obj1[this._sortIndex] < obj2[this._sortIndex])
|
||||
{
|
||||
return this._sortOrder;
|
||||
}
|
||||
else if (Obj1[this._sortIndex] > Obj2[this._sortIndex])
|
||||
else if (obj1[this._sortIndex] > obj2[this._sortIndex])
|
||||
{
|
||||
return -this._sortOrder;
|
||||
}
|
||||
@@ -37,21 +37,6 @@ module Phaser {
|
||||
return this.setTo(source.x, source.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the x and y values from this Point to any given object.
|
||||
* @method copyTo
|
||||
* @param {any} target - The object to copy to.
|
||||
* @return {any} The target object.
|
||||
**/
|
||||
public copyTo(target: any): Point {
|
||||
|
||||
target.x = this.x;
|
||||
target.y = this.y;
|
||||
|
||||
return target;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverts the x and y values of this Point
|
||||
* @method invert
|
||||
|
||||
@@ -300,6 +300,16 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the x, y, width and height properties from any given object to this Rectangle.
|
||||
* @method copyFrom
|
||||
* @param {any} source - The object to copy from.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
public copyFrom(source: any): Rectangle {
|
||||
return this.setTo(source.x, source.y, source.width, source.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
|
||||
@@ -39,6 +39,16 @@ module Phaser {
|
||||
**/
|
||||
public y: number;
|
||||
|
||||
/**
|
||||
* Copies the x and y properties from any given object to this Vec2.
|
||||
* @method copyFrom
|
||||
* @param {any} source - The object to copy from.
|
||||
* @return {Vec2} This Vec2 object.
|
||||
**/
|
||||
public copyFrom(source: any): Vec2 {
|
||||
return this.setTo(source.x, source.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the x and y properties of the Vector.
|
||||
* @param {Number} x The x position of the vector
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - DynamicTexture
|
||||
@@ -23,7 +23,8 @@ module Phaser {
|
||||
*/
|
||||
constructor(game: Game, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
this.game = game;
|
||||
this.type = Phaser.Types.GEOMSPRITE;
|
||||
|
||||
this.canvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
this.canvas.width = width;
|
||||
@@ -35,9 +36,14 @@ module Phaser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to game.
|
||||
* Reference to game.
|
||||
*/
|
||||
private _game: Game;
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* The type of game object.
|
||||
*/
|
||||
public type: number;
|
||||
|
||||
private _sx: number = 0;
|
||||
private _sy: number = 0;
|
||||
@@ -176,15 +182,15 @@ module Phaser {
|
||||
// TODO - Load a frame from a sprite sheet, otherwise we'll draw the whole lot
|
||||
if (frame > -1)
|
||||
{
|
||||
//if (this._game.cache.isSpriteSheet(key))
|
||||
//if (this.game.cache.isSpriteSheet(key))
|
||||
//{
|
||||
// texture = this._game.cache.getImage(key);
|
||||
//this.animations.loadFrameData(this._game.cache.getFrameData(key));
|
||||
// texture = this.game.cache.getImage(key);
|
||||
//this.animations.loadFrameData(this.game.cache.getFrameData(key));
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = this._game.cache.getImage(key);
|
||||
texture = this.game.cache.getImage(key);
|
||||
this._sw = texture.width;
|
||||
this._sh = texture.height;
|
||||
this._dw = texture.width;
|
||||
@@ -270,7 +276,7 @@ module Phaser {
|
||||
*/
|
||||
public render(x?: number = 0, y?: number = 0) {
|
||||
|
||||
this._game.stage.context.drawImage(this.canvas, x, y);
|
||||
this.game.stage.context.drawImage(this.canvas, x, y);
|
||||
|
||||
}
|
||||
|
||||
Vendored
-38
@@ -1,38 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../Group.d.ts" />
|
||||
module Phaser {
|
||||
class Emitter extends Group {
|
||||
constructor(game: Game, X?: number, Y?: number, Size?: number);
|
||||
public x: number;
|
||||
public y: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
public minParticleSpeed: MicroPoint;
|
||||
public maxParticleSpeed: MicroPoint;
|
||||
public particleDrag: MicroPoint;
|
||||
public minRotation: number;
|
||||
public maxRotation: number;
|
||||
public gravity: number;
|
||||
public on: bool;
|
||||
public frequency: number;
|
||||
public lifespan: number;
|
||||
public bounce: number;
|
||||
public particleClass;
|
||||
private _quantity;
|
||||
private _explode;
|
||||
private _timer;
|
||||
private _counter;
|
||||
private _point;
|
||||
public destroy(): void;
|
||||
public makeParticles(Graphics, Quantity?: number, BakedRotations?: number, Multiple?: bool, Collide?: number): Emitter;
|
||||
public update(): void;
|
||||
public kill(): void;
|
||||
public start(Explode?: bool, Lifespan?: number, Frequency?: number, Quantity?: number): void;
|
||||
public emitParticle(): void;
|
||||
public setSize(Width: number, Height: number): void;
|
||||
public setXSpeed(Min?: number, Max?: number): void;
|
||||
public setYSpeed(Min?: number, Max?: number): void;
|
||||
public setRotation(Min?: number, Max?: number): void;
|
||||
public at(Object): void;
|
||||
}
|
||||
}
|
||||
Vendored
-84
@@ -1,84 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../Basic.d.ts" />
|
||||
/// <reference path="../Signal.d.ts" />
|
||||
module Phaser {
|
||||
class GameObject extends Basic {
|
||||
constructor(game: Game, x?: number, y?: number, width?: number, height?: number);
|
||||
private _angle;
|
||||
static ALIGN_TOP_LEFT: number;
|
||||
static ALIGN_TOP_CENTER: number;
|
||||
static ALIGN_TOP_RIGHT: number;
|
||||
static ALIGN_CENTER_LEFT: number;
|
||||
static ALIGN_CENTER: number;
|
||||
static ALIGN_CENTER_RIGHT: number;
|
||||
static ALIGN_BOTTOM_LEFT: number;
|
||||
static ALIGN_BOTTOM_CENTER: number;
|
||||
static ALIGN_BOTTOM_RIGHT: number;
|
||||
static OUT_OF_BOUNDS_STOP: number;
|
||||
static OUT_OF_BOUNDS_KILL: number;
|
||||
public _point: MicroPoint;
|
||||
public cameraBlacklist: number[];
|
||||
public bounds: Rectangle;
|
||||
public worldBounds: Quad;
|
||||
public outOfBoundsAction: number;
|
||||
public align: number;
|
||||
public facing: number;
|
||||
public alpha: number;
|
||||
public scale: MicroPoint;
|
||||
public origin: MicroPoint;
|
||||
public z: number;
|
||||
public rotationOffset: number;
|
||||
public renderRotation: bool;
|
||||
public immovable: bool;
|
||||
public velocity: MicroPoint;
|
||||
public mass: number;
|
||||
public elasticity: number;
|
||||
public acceleration: MicroPoint;
|
||||
public drag: MicroPoint;
|
||||
public maxVelocity: MicroPoint;
|
||||
public angularVelocity: number;
|
||||
public angularAcceleration: number;
|
||||
public angularDrag: number;
|
||||
public maxAngular: number;
|
||||
public scrollFactor: MicroPoint;
|
||||
public health: number;
|
||||
public moves: bool;
|
||||
public touching: number;
|
||||
public wasTouching: number;
|
||||
public allowCollisions: number;
|
||||
public last: MicroPoint;
|
||||
public inputEnabled: bool;
|
||||
private _inputOver;
|
||||
public onInputOver: Signal;
|
||||
public onInputOut: Signal;
|
||||
public onInputDown: Signal;
|
||||
public onInputUp: Signal;
|
||||
public preUpdate(): void;
|
||||
public update(): void;
|
||||
public postUpdate(): void;
|
||||
private updateInput();
|
||||
private updateMotion();
|
||||
public overlaps(ObjectOrGroup, InScreenSpace?: bool, Camera?: Camera): bool;
|
||||
public overlapsAt(X: number, Y: number, ObjectOrGroup, InScreenSpace?: bool, Camera?: Camera): bool;
|
||||
public overlapsPoint(point: Point, InScreenSpace?: bool, Camera?: Camera): bool;
|
||||
public onScreen(Camera?: Camera): bool;
|
||||
public getScreenXY(point?: MicroPoint, Camera?: Camera): MicroPoint;
|
||||
public solid : bool;
|
||||
public getMidpoint(point?: MicroPoint): MicroPoint;
|
||||
public reset(X: number, Y: number): void;
|
||||
public isTouching(Direction: number): bool;
|
||||
public justTouched(Direction: number): bool;
|
||||
public hurt(Damage: number): void;
|
||||
public setBounds(x: number, y: number, width: number, height: number): void;
|
||||
public hideFromCamera(camera: Camera): void;
|
||||
public showToCamera(camera: Camera): void;
|
||||
public clearCameraList(): void;
|
||||
public destroy(): void;
|
||||
public x : number;
|
||||
public y : number;
|
||||
public rotation : number;
|
||||
public angle : number;
|
||||
public width : number;
|
||||
public height : number;
|
||||
}
|
||||
}
|
||||
@@ -1,897 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../Basic.ts" />
|
||||
/// <reference path="../Signal.ts" />
|
||||
/// <reference path="../system/CollisionMask.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - GameObject
|
||||
*
|
||||
* This is the base GameObject on which all other game objects are derived. It contains all the logic required for position,
|
||||
* motion, size, collision and input.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class GameObject extends Basic {
|
||||
|
||||
/**
|
||||
* GameObject constructor
|
||||
*
|
||||
* Create a new <code>GameObject</code> object at specific position with specific width and height.
|
||||
*
|
||||
* @param [x] {number} The x position of the object.
|
||||
* @param [y] {number} The y position of the object.
|
||||
* @param [width] {number} The width of the object.
|
||||
* @param [height] {number} The height of the object.
|
||||
*/
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0, width?: number = 16, height?: number = 16) {
|
||||
|
||||
super(game);
|
||||
|
||||
this.canvas = game.stage.canvas;
|
||||
this.context = game.stage.context;
|
||||
|
||||
this.frameBounds = new Rectangle(x, y, width, height);
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
this.isGroup = false;
|
||||
this.alpha = 1;
|
||||
this.scale = new MicroPoint(1, 1);
|
||||
|
||||
this.last = new MicroPoint(x, y);
|
||||
this.align = GameObject.ALIGN_TOP_LEFT;
|
||||
this.mass = 1;
|
||||
this.elasticity = 0;
|
||||
this.health = 1;
|
||||
this.immovable = false;
|
||||
this.moves = true;
|
||||
this.worldBounds = null;
|
||||
|
||||
this.touching = Collision.NONE;
|
||||
this.wasTouching = Collision.NONE;
|
||||
this.allowCollisions = Collision.ANY;
|
||||
|
||||
this.velocity = new MicroPoint();
|
||||
this.acceleration = new MicroPoint();
|
||||
this.drag = new MicroPoint();
|
||||
this.maxVelocity = new MicroPoint(10000, 10000);
|
||||
|
||||
this.angle = 0;
|
||||
this.angularVelocity = 0;
|
||||
this.angularAcceleration = 0;
|
||||
this.angularDrag = 0;
|
||||
this.maxAngular = 10000;
|
||||
|
||||
this.cameraBlacklist = [];
|
||||
this.scrollFactor = new MicroPoint(1, 1);
|
||||
this.collisionMask = new CollisionMask(game, this, x, y, width, height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Angle of this object.
|
||||
* @type {number}
|
||||
*/
|
||||
private _angle: number = 0;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the top-left corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_TOP_LEFT: number = 0;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the top-center corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_TOP_CENTER: number = 1;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the top-right corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_TOP_RIGHT: number = 2;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the center-left corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_CENTER_LEFT: number = 3;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the center corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_CENTER: number = 4;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the center-right corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_CENTER_RIGHT: number = 5;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the bottom-left corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_BOTTOM_LEFT: number = 6;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the bottom-center corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_BOTTOM_CENTER: number = 7;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the bottom-right corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_BOTTOM_RIGHT: number = 8;
|
||||
|
||||
/**
|
||||
* Enum value for outOfBoundsAction. Stop the object when is out of world bounds.
|
||||
* @type {number}
|
||||
*/
|
||||
public static OUT_OF_BOUNDS_STOP: number = 0;
|
||||
|
||||
/**
|
||||
* Enum value for outOfBoundsAction. Kill the object when is out of world bounds.
|
||||
* @type {number}
|
||||
*/
|
||||
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[];
|
||||
|
||||
/**
|
||||
* Rectangle container of this object.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public frameBounds: Rectangle;
|
||||
|
||||
/**
|
||||
* This objects CollisionMask
|
||||
* @type {CollisionMask}
|
||||
*/
|
||||
public collisionMask: CollisionMask;
|
||||
|
||||
/**
|
||||
* A rectangular area which is object is allowed to exist within. If it travels outside of this area it will perform the outOfBoundsAction.
|
||||
* @type {Quad}
|
||||
*/
|
||||
public worldBounds: Quad;
|
||||
|
||||
/**
|
||||
* What action will be performed when object is out of the worldBounds.
|
||||
* This will default to GameObject.OUT_OF_BOUNDS_STOP.
|
||||
* @type {number}
|
||||
*/
|
||||
public outOfBoundsAction: number = 0;
|
||||
|
||||
/**
|
||||
* At which point the graphic of this object will align to.
|
||||
* Align of the object will default to GameObject.ALIGN_TOP_LEFT.
|
||||
* @type {number}
|
||||
*/
|
||||
public align: number;
|
||||
|
||||
/**
|
||||
* Orientation of the object.
|
||||
* @type {number}
|
||||
*/
|
||||
public facing: number;
|
||||
|
||||
/**
|
||||
* Set alpha to a number between 0 and 1 to change the opacity.
|
||||
* @type {number}
|
||||
*/
|
||||
public alpha: number;
|
||||
|
||||
/**
|
||||
* Scale factor of the object.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public scale: MicroPoint;
|
||||
|
||||
/**
|
||||
* Origin is the anchor point that the object will rotate by.
|
||||
* The origin will default to its center.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public origin: MicroPoint;
|
||||
|
||||
/**
|
||||
* Z-order value of the object.
|
||||
*/
|
||||
public z: number = 0;
|
||||
|
||||
/**
|
||||
* This value is added to the angle of the GameObject.
|
||||
* For example if you had a sprite drawn facing straight up then you could set
|
||||
* rotationOffset to 90 and it would correspond correctly with Phasers rotation system
|
||||
* @type {number}
|
||||
*/
|
||||
public rotationOffset: number = 0;
|
||||
|
||||
/**
|
||||
* Controls if the GameObject is rendered rotated or not.
|
||||
* If renderRotation is false then the object can still rotate but it will never be rendered rotated.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public renderRotation: bool = true;
|
||||
|
||||
// Physics properties
|
||||
|
||||
/**
|
||||
* Whether this object will be moved by impacts with other objects or not.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public immovable: bool;
|
||||
|
||||
/**
|
||||
* Basic speed of this object.
|
||||
*
|
||||
* Velocity is given in pixels per second. Therefore a velocity of
|
||||
* 100 will move at a rate of 100 pixels every 1000 ms (1sec). It's not balls-on
|
||||
* accurate due to the way timers work, but it's pretty close. Expect tolerance
|
||||
* of +- 10 px. Also that speed assumes no drag.
|
||||
*
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public velocity: MicroPoint;
|
||||
|
||||
/**
|
||||
* The virtual mass of the object.
|
||||
* @type {number}
|
||||
*/
|
||||
public mass: number;
|
||||
|
||||
/**
|
||||
* The bounciness of the object.
|
||||
* @type {number}
|
||||
*/
|
||||
public elasticity: number;
|
||||
|
||||
/**
|
||||
* How fast the speed of this object is changing.
|
||||
* @type {number}
|
||||
*/
|
||||
public acceleration: MicroPoint;
|
||||
|
||||
/**
|
||||
* This isn't drag exactly, more like deceleration that is only applied
|
||||
* when acceleration is not affecting the sprite.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public drag: MicroPoint;
|
||||
|
||||
/**
|
||||
* It will cap the speed automatically if you use the acceleration
|
||||
* to change its velocity.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public maxVelocity: MicroPoint;
|
||||
|
||||
/**
|
||||
* How fast this object is rotating.
|
||||
* @type {number}
|
||||
*/
|
||||
public angularVelocity: number;
|
||||
|
||||
/**
|
||||
* How fast angularVelocity of this object is changing.
|
||||
* @type {number}
|
||||
*/
|
||||
public angularAcceleration: number;
|
||||
|
||||
/**
|
||||
* Deacceleration of angularVelocity will be applied when it's rotating.
|
||||
* @type {number}
|
||||
*/
|
||||
public angularDrag: number;
|
||||
|
||||
/**
|
||||
* It will cap the rotate speed automatically if you use the angularAcceleration
|
||||
* to change its angularVelocity.
|
||||
* @type {number}
|
||||
*/
|
||||
public maxAngular: number;
|
||||
|
||||
/**
|
||||
* A point that can store numbers from 0 to 1 (for X and Y independently)
|
||||
* which governs how much this object is affected by the camera .
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public scrollFactor: MicroPoint;
|
||||
|
||||
/**
|
||||
* Handy for storing health percentage or armor points or whatever.
|
||||
* @type {number}
|
||||
*/
|
||||
public health: number;
|
||||
|
||||
/**
|
||||
* Set this to false if you want to skip the automatic motion/movement stuff
|
||||
* (see updateMotion()).
|
||||
* @type {boolean}
|
||||
*/
|
||||
public moves: bool = true;
|
||||
|
||||
/**
|
||||
* Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts.
|
||||
* @type {number}
|
||||
*/
|
||||
public touching: number;
|
||||
|
||||
/**
|
||||
* Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts from the previous game loop step.
|
||||
* @type {number}
|
||||
*/
|
||||
public wasTouching: number;
|
||||
|
||||
/**
|
||||
* Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions.
|
||||
* @type {number}
|
||||
*/
|
||||
public allowCollisions: number;
|
||||
|
||||
/**
|
||||
* Important variable for collision processing.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public last: MicroPoint;
|
||||
|
||||
// Input
|
||||
public inputEnabled: bool = false;
|
||||
private _inputOver: bool = false;
|
||||
|
||||
public onInputOver: Phaser.Signal;
|
||||
public onInputOut: Phaser.Signal;
|
||||
public onInputDown: Phaser.Signal;
|
||||
public onInputUp: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* Pre-update is called right before update() on each object in the game loop.
|
||||
*/
|
||||
public preUpdate() {
|
||||
|
||||
this.last.x = this.frameBounds.x;
|
||||
this.last.y = this.frameBounds.y;
|
||||
|
||||
this.collisionMask.preUpdate();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this function to update your class's position and appearance.
|
||||
*/
|
||||
public update() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically called after update() by the game loop.
|
||||
*/
|
||||
public postUpdate() {
|
||||
|
||||
if (this.moves)
|
||||
{
|
||||
this.updateMotion();
|
||||
}
|
||||
|
||||
if (this.worldBounds != null)
|
||||
{
|
||||
if (this.outOfBoundsAction == GameObject.OUT_OF_BOUNDS_KILL)
|
||||
{
|
||||
if (this.x < this.worldBounds.x || this.x > this.worldBounds.right || this.y < this.worldBounds.y || this.y > this.worldBounds.bottom)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.x < this.worldBounds.x)
|
||||
{
|
||||
this.x = this.worldBounds.x;
|
||||
}
|
||||
else if (this.x > this.worldBounds.right)
|
||||
{
|
||||
this.x = this.worldBounds.right;
|
||||
}
|
||||
|
||||
if (this.y < this.worldBounds.y)
|
||||
{
|
||||
this.y = this.worldBounds.y;
|
||||
}
|
||||
else if (this.y > this.worldBounds.bottom)
|
||||
{
|
||||
this.y = this.worldBounds.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.collisionMask.update();
|
||||
|
||||
if (this.inputEnabled)
|
||||
{
|
||||
this.updateInput();
|
||||
}
|
||||
|
||||
this.wasTouching = this.touching;
|
||||
this.touching = Collision.NONE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update input.
|
||||
*/
|
||||
private updateInput() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function for updating the position and speed of this object.
|
||||
*/
|
||||
private updateMotion() {
|
||||
|
||||
var delta: number;
|
||||
var velocityDelta: number;
|
||||
|
||||
velocityDelta = (this._game.motion.computeVelocity(this.angularVelocity, this.angularAcceleration, this.angularDrag, this.maxAngular) - this.angularVelocity) / 2;
|
||||
this.angularVelocity += velocityDelta;
|
||||
this._angle += this.angularVelocity * this._game.time.elapsed;
|
||||
this.angularVelocity += velocityDelta;
|
||||
|
||||
velocityDelta = (this._game.motion.computeVelocity(this.velocity.x, this.acceleration.x, this.drag.x, this.maxVelocity.x) - this.velocity.x) / 2;
|
||||
this.velocity.x += velocityDelta;
|
||||
delta = this.velocity.x * this._game.time.elapsed;
|
||||
this.velocity.x += velocityDelta;
|
||||
this.frameBounds.x += delta;
|
||||
|
||||
velocityDelta = (this._game.motion.computeVelocity(this.velocity.y, this.acceleration.y, this.drag.y, this.maxVelocity.y) - this.velocity.y) / 2;
|
||||
this.velocity.y += velocityDelta;
|
||||
delta = this.velocity.y * this._game.time.elapsed;
|
||||
this.velocity.y += velocityDelta;
|
||||
this.frameBounds.y += delta;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if some <code>GameObject</code> overlaps this <code>GameObject</code> or <code>Group</code>.
|
||||
* If the group has a LOT of things in it, it might be faster to use <code>Collision.overlaps()</code>.
|
||||
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
|
||||
*
|
||||
* @param objectOrGroup {object} The object or group being tested.
|
||||
* @param inScreenSpace {boolean} Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
|
||||
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return {boolean} Whether or not the objects overlap this.
|
||||
*/
|
||||
public overlaps(objectOrGroup, inScreenSpace: bool = false, camera: Camera = null): bool {
|
||||
|
||||
if (objectOrGroup.isGroup)
|
||||
{
|
||||
var results: bool = false;
|
||||
var i: number = 0;
|
||||
var members = <Group> objectOrGroup.members;
|
||||
|
||||
while (i < length)
|
||||
{
|
||||
if (this.overlaps(members[i++], inScreenSpace, camera))
|
||||
{
|
||||
results = true;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
|
||||
}
|
||||
|
||||
if (!inScreenSpace)
|
||||
{
|
||||
return (objectOrGroup.x + objectOrGroup.width > this.x) && (objectOrGroup.x < this.x + this.width) &&
|
||||
(objectOrGroup.y + objectOrGroup.height > this.y) && (objectOrGroup.y < this.y + this.height);
|
||||
}
|
||||
|
||||
if (camera == null)
|
||||
{
|
||||
camera = this._game.camera;
|
||||
}
|
||||
|
||||
var objectScreenPos: Point = objectOrGroup.getScreenXY(null, camera);
|
||||
|
||||
this.getScreenXY(this._point, camera);
|
||||
|
||||
return (objectScreenPos.x + objectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) &&
|
||||
(objectScreenPos.y + objectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if this <code>GameObject</code> were located at the given position, would it overlap the <code>GameObject</code> or <code>Group</code>?
|
||||
* This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size numbero account.
|
||||
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
|
||||
*
|
||||
* @param X {number} The X position you want to check. Pretends this object (the caller, not the parameter) is located here.
|
||||
* @param Y {number} The Y position you want to check. Pretends this object (the caller, not the parameter) is located here.
|
||||
* @param objectOrGroup {object} The object or group being tested.
|
||||
* @param inScreenSpace {boolean} Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
|
||||
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return {boolean} Whether or not the two objects overlap.
|
||||
*/
|
||||
public overlapsAt(X: number, Y: number, objectOrGroup, inScreenSpace: bool = false, camera: Camera = null): bool {
|
||||
|
||||
if (objectOrGroup.isGroup)
|
||||
{
|
||||
var results: bool = false;
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
var members = objectOrGroup.members;
|
||||
|
||||
while (i < length)
|
||||
{
|
||||
if (this.overlapsAt(X, Y, members[i++], inScreenSpace, camera))
|
||||
{
|
||||
results = true;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
if (!inScreenSpace)
|
||||
{
|
||||
return (objectOrGroup.x + objectOrGroup.width > X) && (objectOrGroup.x < X + this.width) &&
|
||||
(objectOrGroup.y + objectOrGroup.height > Y) && (objectOrGroup.y < Y + this.height);
|
||||
}
|
||||
|
||||
if (camera == null)
|
||||
{
|
||||
camera = this._game.camera;
|
||||
}
|
||||
|
||||
var objectScreenPos: Point = objectOrGroup.getScreenXY(null, Camera);
|
||||
|
||||
this._point.x = X - camera.scroll.x * this.scrollFactor.x; //copied from getScreenXY()
|
||||
this._point.y = Y - camera.scroll.y * this.scrollFactor.y;
|
||||
this._point.x += (this._point.x > 0) ? 0.0000001 : -0.0000001;
|
||||
this._point.y += (this._point.y > 0) ? 0.0000001 : -0.0000001;
|
||||
|
||||
return (objectScreenPos.x + objectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) &&
|
||||
(objectScreenPos.y + objectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a point in 2D world space overlaps this <code>GameObject</code>.
|
||||
*
|
||||
* @param point {Point} The point in world space you want to check.
|
||||
* @param inScreenSpace {boolean} Whether to take scroll factors into account when checking for overlap.
|
||||
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return Whether or not the point overlaps this object.
|
||||
*/
|
||||
public overlapsPoint(point: Point, inScreenSpace: bool = false, camera: Camera = null): bool {
|
||||
|
||||
if (!inScreenSpace)
|
||||
{
|
||||
return (point.x > this.x) && (point.x < this.x + this.width) && (point.y > this.y) && (point.y < this.y + this.height);
|
||||
}
|
||||
|
||||
if (camera == null)
|
||||
{
|
||||
camera = this._game.camera;
|
||||
}
|
||||
|
||||
var X: number = point.x - camera.scroll.x;
|
||||
var Y: number = point.y - camera.scroll.y;
|
||||
|
||||
this.getScreenXY(this._point, camera);
|
||||
|
||||
return (X > this._point.x) && (X < this._point.x + this.width) && (Y > this._point.y) && (Y < this._point.y + this.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and see if this object is currently on screen.
|
||||
*
|
||||
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return {boolean} Whether the object is on screen or not.
|
||||
*/
|
||||
public onScreen(camera: Camera = null): bool {
|
||||
|
||||
if (camera == null)
|
||||
{
|
||||
camera = this._game.camera;
|
||||
}
|
||||
|
||||
this.getScreenXY(this._point, camera);
|
||||
|
||||
return (this._point.x + this.width > 0) && (this._point.x < camera.width) && (this._point.y + this.height > 0) && (this._point.y < camera.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to figure out the on-screen position of the object.
|
||||
*
|
||||
* @param point {Point} Takes a <code>MicroPoint</code> object and assigns the post-scrolled X and Y values of this object to it.
|
||||
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return {MicroPoint} The <code>MicroPoint</code> you passed in, or a new <code>Point</code> if you didn't pass one, containing the screen X and Y position of this object.
|
||||
*/
|
||||
public getScreenXY(point: MicroPoint = null, camera: Camera = null): MicroPoint {
|
||||
|
||||
if (point == null)
|
||||
{
|
||||
point = new MicroPoint();
|
||||
}
|
||||
|
||||
if (camera == null)
|
||||
{
|
||||
camera = this._game.camera;
|
||||
}
|
||||
|
||||
point.x = this.x - camera.scroll.x * this.scrollFactor.x;
|
||||
point.y = this.y - camera.scroll.y * this.scrollFactor.y;
|
||||
point.x += (point.x > 0) ? 0.0000001 : -0.0000001;
|
||||
point.y += (point.y > 0) ? 0.0000001 : -0.0000001;
|
||||
|
||||
return point;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the object collides or not. For more control over what directions
|
||||
* the object will collide from, use collision constants (like LEFT, FLOOR, etc)
|
||||
* to set the value of allowCollisions directly.
|
||||
*/
|
||||
public get solid(): bool {
|
||||
return (this.allowCollisions & Collision.ANY) > Collision.NONE;
|
||||
}
|
||||
|
||||
public set solid(value: bool) {
|
||||
|
||||
if (value)
|
||||
{
|
||||
this.allowCollisions = Collision.ANY;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowCollisions = Collision.NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the midpoint of this object in world coordinates.
|
||||
*
|
||||
* @param point {Point} Allows you to pass in an existing <code>Point</code> object if you're so inclined. Otherwise a new one is created.
|
||||
*
|
||||
* @return {MicroPoint} A <code>Point</code> object containing the midpoint of this object in world coordinates.
|
||||
*/
|
||||
public getMidpoint(point: MicroPoint = null): MicroPoint {
|
||||
|
||||
if (point == null)
|
||||
{
|
||||
point = new MicroPoint();
|
||||
}
|
||||
|
||||
point.copyFrom(this.frameBounds.center);
|
||||
|
||||
return point;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for reviving game objects.
|
||||
* Resets their existence flags and position.
|
||||
*
|
||||
* @param x {number} The new X position of this object.
|
||||
* @param y {number} The new Y position of this object.
|
||||
*/
|
||||
public reset(x: number, y: number) {
|
||||
|
||||
this.revive();
|
||||
this.touching = Collision.NONE;
|
||||
this.wasTouching = Collision.NONE;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.last.x = x;
|
||||
this.last.y = y;
|
||||
this.velocity.x = 0;
|
||||
this.velocity.y = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for checking if this object is touching a particular surface.
|
||||
* For slightly better performance you can just & the value directly into <code>touching</code>.
|
||||
* However, this method is good for readability and accessibility.
|
||||
*
|
||||
* @param Direction {number} Any of the collision flags (e.g. LEFT, FLOOR, etc).
|
||||
*
|
||||
* @return {boolean} Whether the object is touching an object in (any of) the specified direction(s) this frame.
|
||||
*/
|
||||
public isTouching(direction: number): bool {
|
||||
return (this.touching & direction) > Collision.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy function for checking if this object just landed on a particular surface.
|
||||
*
|
||||
* @param Direction {number} Any of the collision flags (e.g. LEFT, FLOOR, etc).
|
||||
*
|
||||
* @returns {boolean} Whether the object just landed on any specicied surfaces.
|
||||
*/
|
||||
public justTouched(direction: number): bool {
|
||||
return ((this.touching & direction) > Collision.NONE) && ((this.wasTouching & direction) <= Collision.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduces the "health" variable of this sprite by the amount specified in Damage.
|
||||
* Calls kill() if health drops to or below zero.
|
||||
*
|
||||
* @param Damage {number} How much health to take away (use a negative number to give a health bonus).
|
||||
*/
|
||||
public hurt(damage: number) {
|
||||
|
||||
this.health = this.health - damage;
|
||||
|
||||
if (this.health <= 0)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the world bounds that this GameObject can exist within. By default a GameObject can exist anywhere
|
||||
* in the world. But by setting the bounds (which are given in world dimensions, not screen dimensions)
|
||||
* it can be stopped from leaving the world, or a section of it.
|
||||
*
|
||||
* @param x {number} x position of the bound
|
||||
* @param y {number} y position of the bound
|
||||
* @param width {number} width of its bound
|
||||
* @param height {number} height of its bound
|
||||
*/
|
||||
public setBounds(x: number, y: number, width: number, height: number) {
|
||||
|
||||
this.worldBounds = new Quad(x, y, width, height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param camera {Camera} The specific camera.
|
||||
*/
|
||||
public hideFromCamera(camera: Camera) {
|
||||
|
||||
if (this.cameraBlacklist.indexOf(camera.ID) == -1)
|
||||
{
|
||||
this.cameraBlacklist.push(camera.ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make this object only visible to a specific camera.
|
||||
*
|
||||
* @param camera {Camera} The camera you wish it to be visible.
|
||||
*/
|
||||
public showToCamera(camera: Camera) {
|
||||
|
||||
if (this.cameraBlacklist.indexOf(camera.ID) !== -1)
|
||||
{
|
||||
this.cameraBlacklist.slice(this.cameraBlacklist.indexOf(camera.ID), 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This clears the camera black list, making the GameObject visible to all cameras.
|
||||
*/
|
||||
public clearCameraList() {
|
||||
|
||||
this.cameraBlacklist.length = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
}
|
||||
|
||||
public setPosition(x: number, y: number) {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
return this.frameBounds.x;
|
||||
}
|
||||
|
||||
public set x(value: number) {
|
||||
this.frameBounds.x = value;
|
||||
}
|
||||
|
||||
public get y(): number {
|
||||
return this.frameBounds.y;
|
||||
}
|
||||
|
||||
public set y(value: number) {
|
||||
this.frameBounds.y = value;
|
||||
}
|
||||
|
||||
public get rotation(): number {
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
public set rotation(value: number) {
|
||||
this._angle = this._game.math.wrap(value, 360, 0);
|
||||
}
|
||||
|
||||
public get angle(): number {
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
public set angle(value: number) {
|
||||
this._angle = this._game.math.wrap(value, 360, 0);
|
||||
}
|
||||
|
||||
public set width(value:number) {
|
||||
this.frameBounds.width = value;
|
||||
}
|
||||
|
||||
public set height(value:number) {
|
||||
this.frameBounds.height = value;
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.frameBounds.width;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.frameBounds.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../tweens/Tween.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - GameObjectFactory
|
||||
@@ -41,7 +42,7 @@ module Phaser {
|
||||
* @returns {Camera} The newly created camera object.
|
||||
*/
|
||||
public camera(x: number, y: number, width: number, height: number): Camera {
|
||||
return this._world.createCamera(x, y, width, height);
|
||||
return this._world.cameras.addCamera(x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,9 +52,9 @@ module Phaser {
|
||||
* @param y {number} Y position of the new geom sprite.
|
||||
* @returns {GeomSprite} The newly created geom sprite object.
|
||||
*/
|
||||
public geomSprite(x: number, y: number): GeomSprite {
|
||||
return this._world.createGeomSprite(x, y);
|
||||
}
|
||||
//public geomSprite(x: number, y: number): GeomSprite {
|
||||
// return <GeomSprite> this._world.group.add(new GeomSprite(this._game, x, y));
|
||||
//}
|
||||
|
||||
/**
|
||||
* Create a new Sprite with specific position and sprite sheet key.
|
||||
@@ -64,7 +65,7 @@ module Phaser {
|
||||
* @returns {Sprite} The newly created sprite object.
|
||||
*/
|
||||
public sprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
return this._world.createSprite(x, y, key);
|
||||
return <Sprite> this._world.group.add(new Sprite(this._game, x, y, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +76,7 @@ module Phaser {
|
||||
* @returns {DynamicTexture} The newly created dynamic texture object.
|
||||
*/
|
||||
public dynamicTexture(width: number, height: number): DynamicTexture {
|
||||
return this._world.createDynamicTexture(width, height);
|
||||
return new DynamicTexture(this._game, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +86,7 @@ module Phaser {
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public group(maxSize?: number = 0): Group {
|
||||
return this._world.createGroup(maxSize);
|
||||
return <Group> this._world.group.add(new Group(this._game, maxSize));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,9 +94,9 @@ module Phaser {
|
||||
*
|
||||
* @return {Particle} The newly created particle object.
|
||||
*/
|
||||
public particle(): Particle {
|
||||
return this._world.createParticle();
|
||||
}
|
||||
//public particle(): Particle {
|
||||
// return new Particle(this._game);
|
||||
//}
|
||||
|
||||
/**
|
||||
* Create a new Emitter.
|
||||
@@ -105,9 +106,9 @@ module Phaser {
|
||||
* @param size {number} Optional, size of this emitter.
|
||||
* @return {Emitter} The newly created emitter object.
|
||||
*/
|
||||
public emitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
return this._world.createEmitter(x, y, size);
|
||||
}
|
||||
//public emitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
// return <Emitter> this._world.group.add(new Emitter(this._game, x, y, size));
|
||||
//}
|
||||
|
||||
/**
|
||||
* Create a new ScrollZone object with image key, position and size.
|
||||
@@ -119,9 +120,9 @@ module Phaser {
|
||||
* @param height {number} Height of this object.
|
||||
* @returns {ScrollZone} The newly created scroll zone object.
|
||||
*/
|
||||
public scrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
|
||||
return this._world.createScrollZone(key, x, y, width, height);
|
||||
}
|
||||
//public scrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
|
||||
// return <ScrollZone> this._world.group.add(new ScrollZone(this._game, key, x, y, width, height));
|
||||
//}
|
||||
|
||||
/**
|
||||
* Create a new Tilemap.
|
||||
@@ -135,7 +136,7 @@ module Phaser {
|
||||
* @return {Tilemap} The newly created tilemap object.
|
||||
*/
|
||||
public tilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
|
||||
return this._world.createTilemap(key, mapData, format, resizeWorld, tileWidth, tileHeight);
|
||||
return <Tilemap> this._world.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,9 +167,9 @@ module Phaser {
|
||||
* @param sprite The GeomSprite to add to the Game World
|
||||
* @return {Phaser.GeomSprite} The GeomSprite object
|
||||
*/
|
||||
public existingGeomSprite(sprite: GeomSprite): GeomSprite {
|
||||
return this._world.group.add(sprite);
|
||||
}
|
||||
//public existingGeomSprite(sprite: GeomSprite): GeomSprite {
|
||||
// return this._world.group.add(sprite);
|
||||
//}
|
||||
|
||||
/**
|
||||
* Add an existing Emitter to the current world.
|
||||
@@ -177,9 +178,9 @@ module Phaser {
|
||||
* @param emitter The Emitter to add to the Game World
|
||||
* @return {Phaser.Emitter} The Emitter object
|
||||
*/
|
||||
public existingEmitter(emitter: Emitter): Emitter {
|
||||
return this._world.group.add(emitter);
|
||||
}
|
||||
//public existingEmitter(emitter: Emitter): Emitter {
|
||||
// return this._world.group.add(emitter);
|
||||
//}
|
||||
|
||||
/**
|
||||
* Add an existing ScrollZone to the current world.
|
||||
@@ -188,9 +189,9 @@ module Phaser {
|
||||
* @param scrollZone The ScrollZone to add to the Game World
|
||||
* @return {Phaser.ScrollZone} The ScrollZone object
|
||||
*/
|
||||
public existingScrollZone(scrollZone: ScrollZone): ScrollZone {
|
||||
return this._world.group.add(scrollZone);
|
||||
}
|
||||
//public existingScrollZone(scrollZone: ScrollZone): ScrollZone {
|
||||
// return this._world.group.add(scrollZone);
|
||||
//}
|
||||
|
||||
/**
|
||||
* Add an existing Tilemap to the current world.
|
||||
Vendored
-40
@@ -1,40 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class GeomSprite extends GameObject {
|
||||
constructor(game: Game, x?: number, y?: number);
|
||||
private _dx;
|
||||
private _dy;
|
||||
private _dw;
|
||||
private _dh;
|
||||
public type: number;
|
||||
static UNASSIGNED: number;
|
||||
static CIRCLE: number;
|
||||
static LINE: number;
|
||||
static POINT: number;
|
||||
static RECTANGLE: number;
|
||||
public circle: Circle;
|
||||
public line: Line;
|
||||
public point: Point;
|
||||
public rect: Rectangle;
|
||||
public renderOutline: bool;
|
||||
public renderFill: bool;
|
||||
public lineWidth: number;
|
||||
public lineColor: string;
|
||||
public fillColor: string;
|
||||
public loadCircle(circle: Circle): GeomSprite;
|
||||
public loadLine(line: Line): GeomSprite;
|
||||
public loadPoint(point: Point): GeomSprite;
|
||||
public loadRectangle(rect: Rectangle): GeomSprite;
|
||||
public createCircle(diameter: number): GeomSprite;
|
||||
public createLine(x: number, y: number): GeomSprite;
|
||||
public createPoint(): GeomSprite;
|
||||
public createRectangle(width: number, height: number): GeomSprite;
|
||||
public refresh(): void;
|
||||
public update(): void;
|
||||
public inCamera(camera: Rectangle): bool;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool;
|
||||
public renderPoint(offsetX, offsetY, point, size): void;
|
||||
public renderDebugInfo(x: number, y: number, color?: string): void;
|
||||
public collide(source: GeomSprite): bool;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../geom/Polygon.ts" />
|
||||
/// <reference path="../utils/RectangleUtils.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - GeomSprite
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class GeomSprite extends GameObject {
|
||||
export class GeomSprite extends Sprite {
|
||||
|
||||
/**
|
||||
* GeomSprite constructor
|
||||
@@ -262,11 +263,11 @@ module Phaser {
|
||||
* @param height {Number} Height of the rectangle
|
||||
* @return {GeomSprite} GeomSprite instance.
|
||||
*/
|
||||
createPolygon(points?: Vector2[] = []): GeomSprite {
|
||||
createPolygon(points?: Vec2[] = []): GeomSprite {
|
||||
|
||||
this.refresh();
|
||||
this.polygon = new Polygon(new Vector2(this.x, this.y), points);
|
||||
this.type = GeomSprite.POLYGON;
|
||||
//this.refresh();
|
||||
//this.polygon = new Polygon(new Vec2(this.x, this.y), points);
|
||||
//this.type = GeomSprite.POLYGON;
|
||||
//this.frameBounds.copyFrom(this.rect);
|
||||
return this;
|
||||
|
||||
@@ -326,6 +327,7 @@ module Phaser {
|
||||
* @param camera {Rectangle} The rectangle you want to check.
|
||||
* @return {boolean} Return true if bounds of this sprite intersects the given rectangle, otherwise return false.
|
||||
*/
|
||||
/*
|
||||
public inCamera(camera: Rectangle): bool {
|
||||
|
||||
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
|
||||
@@ -343,6 +345,7 @@ module Phaser {
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Render this sprite to specific camera. Called by game loop after update().
|
||||
@@ -354,10 +357,10 @@ module Phaser {
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool {
|
||||
|
||||
// Render checks
|
||||
if (this.type == GeomSprite.UNASSIGNED || this.visible === false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//if (this.type == GeomSprite.UNASSIGNED || this.visible === false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
|
||||
@@ -0,0 +1,355 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../AnimationManager.ts" />
|
||||
/// <reference path="GameObject.ts" />
|
||||
/// <reference path="../system/Camera.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Sprite
|
||||
*
|
||||
* The Sprite GameObject is an extension of the core GameObject that includes support for animation and dynamic textures.
|
||||
* It's probably the most used GameObject of all.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class OldSprite {
|
||||
|
||||
/**
|
||||
* Sprite constructor
|
||||
* Create a new <code>Sprite</code>.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
* @param [x] {number} the initial x position of the sprite.
|
||||
* @param [y] {number} the initial y position of the sprite.
|
||||
* @param [key] {string} Key of the graphic you want to load for this sprite.
|
||||
* @param [width] {number} The width of the object.
|
||||
* @param [height] {number} The height of the object.
|
||||
*/
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null, width?: number = 16, height?: number = 16) {
|
||||
|
||||
this.canvas = game.stage.canvas;
|
||||
this.context = game.stage.context;
|
||||
|
||||
this.frameBounds = new Rectangle(x, y, width, height);
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
this.isGroup = false;
|
||||
this.alpha = 1;
|
||||
this.scale = new MicroPoint(1, 1);
|
||||
|
||||
this.last = new MicroPoint(x, y);
|
||||
this.align = GameObject.ALIGN_TOP_LEFT;
|
||||
this.mass = 1;
|
||||
this.elasticity = 0;
|
||||
this.health = 1;
|
||||
this.immovable = false;
|
||||
this.moves = true;
|
||||
this.worldBounds = null;
|
||||
|
||||
this.touching = Collision.NONE;
|
||||
this.wasTouching = Collision.NONE;
|
||||
this.allowCollisions = Collision.ANY;
|
||||
|
||||
this.velocity = new MicroPoint();
|
||||
this.acceleration = new MicroPoint();
|
||||
this.drag = new MicroPoint();
|
||||
this.maxVelocity = new MicroPoint(10000, 10000);
|
||||
|
||||
this.angle = 0;
|
||||
this.angularVelocity = 0;
|
||||
this.angularAcceleration = 0;
|
||||
this.angularDrag = 0;
|
||||
this.maxAngular = 10000;
|
||||
|
||||
this.cameraBlacklist = [];
|
||||
this.scrollFactor = new MicroPoint(1, 1);
|
||||
this.collisionMask = new CollisionMask(game, this, x, y, width, height);
|
||||
|
||||
|
||||
this._texture = null;
|
||||
|
||||
this.animations = new AnimationManager(this._game, this);
|
||||
|
||||
if (key !== null)
|
||||
{
|
||||
this.cacheKey = key;
|
||||
this.loadGraphic(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.frameBounds.width = 16;
|
||||
this.frameBounds.height = 16;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object
|
||||
*/
|
||||
public _game: Game;
|
||||
|
||||
/**
|
||||
* Controls whether <code>update()</code> is automatically called by State/Group.
|
||||
*/
|
||||
public active: bool;
|
||||
|
||||
/**
|
||||
* Controls whether <code>draw()</code> is automatically called by State/Group.
|
||||
*/
|
||||
public visible: 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;
|
||||
|
||||
/**
|
||||
* An Array of Cameras to which this GameObject won't render
|
||||
* @type {Array}
|
||||
*/
|
||||
public cameraBlacklist: number[];
|
||||
|
||||
/**
|
||||
* Orientation of the object.
|
||||
* @type {number}
|
||||
*/
|
||||
public facing: number;
|
||||
|
||||
/**
|
||||
* Set alpha to a number between 0 and 1 to change the opacity.
|
||||
* @type {number}
|
||||
*/
|
||||
public alpha: number;
|
||||
|
||||
/**
|
||||
* Scale factor of the object.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public scale: MicroPoint;
|
||||
|
||||
/**
|
||||
* Controls if the GameObject is rendered rotated or not.
|
||||
* If renderRotation is false then the object can still rotate but it will never be rendered rotated.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public renderRotation: bool = true;
|
||||
|
||||
/**
|
||||
* A point that can store numbers from 0 to 1 (for X and Y independently)
|
||||
* which governs how much this object is affected by the camera .
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public scrollFactor: MicroPoint;
|
||||
|
||||
/**
|
||||
* Rectangle container of this object.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public frameBounds: Rectangle;
|
||||
|
||||
/**
|
||||
* This objects CollisionMask
|
||||
* @type {CollisionMask}
|
||||
*/
|
||||
public collisionMask: CollisionMask;
|
||||
|
||||
/**
|
||||
* A rectangular area which is object is allowed to exist within. If it travels outside of this area it will perform the outOfBoundsAction.
|
||||
* @type {Quad}
|
||||
*/
|
||||
public worldBounds: Quad;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Texture of this sprite to be rendered.
|
||||
*/
|
||||
private _texture;
|
||||
|
||||
/**
|
||||
* Texture of this sprite is DynamicTexture? (default to false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
private _dynamicTexture: bool = false;
|
||||
|
||||
|
||||
/**
|
||||
* This manages animations of the sprite. You can modify animations though it. (see AnimationManager)
|
||||
* @type AnimationManager
|
||||
*/
|
||||
public animations: AnimationManager;
|
||||
|
||||
/**
|
||||
* The cache key that was used for this texture (if any)
|
||||
*/
|
||||
public cacheKey: string;
|
||||
|
||||
|
||||
/**
|
||||
* Flip the graphic horizontally? (defaults to false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public flipped: bool = false;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pre-update is called right before update() on each object in the game loop.
|
||||
*/
|
||||
public preUpdate() {
|
||||
|
||||
this.last.x = this.frameBounds.x;
|
||||
this.last.y = this.frameBounds.y;
|
||||
|
||||
this.collisionMask.preUpdate();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this function to update your class's position and appearance.
|
||||
*/
|
||||
public update() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically called after update() by the game loop.
|
||||
*/
|
||||
public postUpdate() {
|
||||
|
||||
this.animations.update();
|
||||
|
||||
if (this.moves)
|
||||
{
|
||||
this.updateMotion();
|
||||
}
|
||||
|
||||
if (this.worldBounds != null)
|
||||
{
|
||||
if (this.outOfBoundsAction == GameObject.OUT_OF_BOUNDS_KILL)
|
||||
{
|
||||
if (this.x < this.worldBounds.x || this.x > this.worldBounds.right || this.y < this.worldBounds.y || this.y > this.worldBounds.bottom)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.x < this.worldBounds.x)
|
||||
{
|
||||
this.x = this.worldBounds.x;
|
||||
}
|
||||
else if (this.x > this.worldBounds.right)
|
||||
{
|
||||
this.x = this.worldBounds.right;
|
||||
}
|
||||
|
||||
if (this.y < this.worldBounds.y)
|
||||
{
|
||||
this.y = this.worldBounds.y;
|
||||
}
|
||||
else if (this.y > this.worldBounds.bottom)
|
||||
{
|
||||
this.y = this.worldBounds.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.collisionMask.update();
|
||||
|
||||
if (this.inputEnabled)
|
||||
{
|
||||
this.updateInput();
|
||||
}
|
||||
|
||||
this.wasTouching = this.touching;
|
||||
this.touching = Collision.NONE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
}
|
||||
|
||||
public set width(value:number) {
|
||||
this.frameBounds.width = value;
|
||||
}
|
||||
|
||||
public set height(value:number) {
|
||||
this.frameBounds.height = value;
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.frameBounds.width;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.frameBounds.height;
|
||||
}
|
||||
|
||||
public set frame(value: number) {
|
||||
this.animations.frame = value;
|
||||
}
|
||||
|
||||
public get frame(): number {
|
||||
return this.animations.frame;
|
||||
}
|
||||
|
||||
public set frameName(value: string) {
|
||||
this.animations.frameName = value;
|
||||
}
|
||||
|
||||
public get frameName(): string {
|
||||
return this.animations.frameName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for "killing" game objects.
|
||||
* Default behavior is to flag them as nonexistent AND dead.
|
||||
* However, if you want the "corpse" to remain in the game,
|
||||
* like to animate an effect or whatever, you should override this,
|
||||
* setting only alive to false, and leaving exists true.
|
||||
*/
|
||||
public kill() {
|
||||
this.alive = false;
|
||||
this.exists = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for bringing game objects "back to life". Just sets alive and exists back to true.
|
||||
* In practice, this is most often called by <code>Object.reset()</code>.
|
||||
*/
|
||||
public revive() {
|
||||
this.alive = true;
|
||||
this.exists = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert object to readable string name. Useful for debugging, save games, etc.
|
||||
*/
|
||||
public toString(): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="Sprite.d.ts" />
|
||||
module Phaser {
|
||||
class Particle extends Sprite {
|
||||
constructor(game: Game);
|
||||
public lifespan: number;
|
||||
public friction: number;
|
||||
public update(): void;
|
||||
public onEmit(): void;
|
||||
}
|
||||
}
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../geom/Quad.d.ts" />
|
||||
module Phaser {
|
||||
class ScrollRegion {
|
||||
constructor(x: number, y: number, width: number, height: number, speedX: number, speedY: number);
|
||||
private _A;
|
||||
private _B;
|
||||
private _C;
|
||||
private _D;
|
||||
private _bounds;
|
||||
private _scroll;
|
||||
private _anchorWidth;
|
||||
private _anchorHeight;
|
||||
private _inverseWidth;
|
||||
private _inverseHeight;
|
||||
public visible: bool;
|
||||
public scrollSpeed: MicroPoint;
|
||||
public update(delta: number): void;
|
||||
public render(context: CanvasRenderingContext2D, texture, dx: number, dy: number, dw: number, dh: number): void;
|
||||
private crop(context, texture, srcX, srcY, srcW, srcH, destX, destY, destW, destH, offsetX, offsetY);
|
||||
}
|
||||
}
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../geom/Quad.d.ts" />
|
||||
/// <reference path="ScrollRegion.d.ts" />
|
||||
module Phaser {
|
||||
class ScrollZone extends GameObject {
|
||||
constructor(game: Game, key: string, x?: number, y?: number, width?: number, height?: number);
|
||||
private _texture;
|
||||
private _dynamicTexture;
|
||||
private _dx;
|
||||
private _dy;
|
||||
private _dw;
|
||||
private _dh;
|
||||
public currentRegion: ScrollRegion;
|
||||
public regions: ScrollRegion[];
|
||||
public flipped: bool;
|
||||
public addRegion(x: number, y: number, width: number, height: number, speedX?: number, speedY?: number): ScrollRegion;
|
||||
public setSpeed(x: number, y: number): ScrollZone;
|
||||
public update(): void;
|
||||
public inCamera(camera: Rectangle): bool;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool;
|
||||
private createRepeatingTexture(regionWidth, regionHeight);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../geom/Quad.ts" />
|
||||
/// <reference path="ScrollRegion.ts" />
|
||||
/// <reference path="../core/Rectangle.ts" />
|
||||
/// <reference path="../components/ScrollRegion.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - ScrollZone
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class ScrollZone extends GameObject {
|
||||
export class ScrollZone extends Sprite {
|
||||
|
||||
/**
|
||||
* ScrollZone constructor
|
||||
|
||||
Vendored
-34
@@ -1,34 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../AnimationManager.d.ts" />
|
||||
/// <reference path="GameObject.d.ts" />
|
||||
/// <reference path="../system/Camera.d.ts" />
|
||||
module Phaser {
|
||||
class Sprite extends GameObject {
|
||||
constructor(game: Game, x?: number, y?: number, key?: string);
|
||||
private _texture;
|
||||
private _dynamicTexture;
|
||||
private _sx;
|
||||
private _sy;
|
||||
private _sw;
|
||||
private _sh;
|
||||
private _dx;
|
||||
private _dy;
|
||||
private _dw;
|
||||
private _dh;
|
||||
public animations: AnimationManager;
|
||||
public renderDebug: bool;
|
||||
public renderDebugColor: string;
|
||||
public renderDebugPointColor: string;
|
||||
public flipped: bool;
|
||||
public loadGraphic(key: string): Sprite;
|
||||
public loadDynamicTexture(texture: DynamicTexture): Sprite;
|
||||
public makeGraphic(width: number, height: number, color?: number): Sprite;
|
||||
public inCamera(camera: Rectangle): bool;
|
||||
public postUpdate(): void;
|
||||
public frame : number;
|
||||
public frameName : string;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool;
|
||||
private renderBounds(camera, cameraOffsetX, cameraOffsetY);
|
||||
public renderDebugInfo(x: number, y: number, color?: string): void;
|
||||
}
|
||||
}
|
||||
+62
-385
@@ -1,456 +1,133 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../AnimationManager.ts" />
|
||||
/// <reference path="GameObject.ts" />
|
||||
/// <reference path="../system/Camera.ts" />
|
||||
/// <reference path="../core/Rectangle.ts" />
|
||||
/// <reference path="../components/animation/AnimationManager.ts" />
|
||||
/// <reference path="../components/sprite/Position.ts" />
|
||||
/// <reference path="../components/sprite/Texture.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Sprite
|
||||
*
|
||||
* The Sprite GameObject is an extension of the core GameObject that includes support for animation and dynamic textures.
|
||||
* It's probably the most used GameObject of all.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Sprite extends GameObject {
|
||||
export class Sprite {
|
||||
|
||||
/**
|
||||
* Sprite constructor
|
||||
* Create a new <code>Sprite</code>.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
* @param [x] {number} the initial x position of the sprite.
|
||||
* @param [y] {number} the initial y position of the sprite.
|
||||
* @param [key] {string} Key of the graphic you want to load for this sprite.
|
||||
* @param [width] {number} The width of the object.
|
||||
* @param [height] {number} The height of the object.
|
||||
*/
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null) {
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null, width?: number = 16, height?: number = 16) {
|
||||
|
||||
super(game, x, y);
|
||||
this.game = game;
|
||||
this.type = Phaser.Types.SPRITE;
|
||||
this.render = game.renderer.renderSprite;
|
||||
|
||||
this._texture = null;
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
|
||||
this.animations = new AnimationManager(this._game, this);
|
||||
this.scrollFactor = new Phaser.Vec2(1, 1);
|
||||
this.scale = new Phaser.Vec2(1, 1);
|
||||
|
||||
if (key !== null)
|
||||
{
|
||||
this.cacheKey = key;
|
||||
this.loadGraphic(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.frameBounds.width = 16;
|
||||
this.frameBounds.height = 16;
|
||||
}
|
||||
this.position = new Phaser.Components.Position(this, x, y);
|
||||
this.texture = new Phaser.Components.Texture(this, key, game.stage.canvas, game.stage.context);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Texture of this sprite to be rendered.
|
||||
* Reference to the main game object
|
||||
*/
|
||||
private _texture;
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* Texture of this sprite is DynamicTexture? (default to false)
|
||||
* @type {boolean}
|
||||
* The type of game object.
|
||||
*/
|
||||
private _dynamicTexture: bool = false;
|
||||
|
||||
// local rendering related temp vars to help avoid gc spikes
|
||||
private _sx: number = 0;
|
||||
private _sy: number = 0;
|
||||
private _sw: number = 0;
|
||||
private _sh: number = 0;
|
||||
private _dx: number = 0;
|
||||
private _dy: number = 0;
|
||||
private _dw: number = 0;
|
||||
private _dh: number = 0;
|
||||
public type: number;
|
||||
|
||||
/**
|
||||
* This manages animations of the sprite. You can modify animations though it. (see AnimationManager)
|
||||
* @type AnimationManager
|
||||
* Reference to the Renderer.renderSprite method. Can be overriden by custom classes.
|
||||
*/
|
||||
public animations: AnimationManager;
|
||||
public render;
|
||||
|
||||
/**
|
||||
* The cache key that was used for this texture (if any)
|
||||
* Controls if both <code>update</code> and render are called by the core game loop.
|
||||
*/
|
||||
public cacheKey: string;
|
||||
public exists: bool;
|
||||
|
||||
/**
|
||||
* Render bound of this sprite for debugging? (default to false)
|
||||
* @type {boolean}
|
||||
* Controls if <code>update()</code> is automatically called by the core game loop.
|
||||
*/
|
||||
public renderDebug: bool = false;
|
||||
public active: bool;
|
||||
|
||||
/**
|
||||
* Color of the Sprite when no image is present. Format is a css color string.
|
||||
* @type {string}
|
||||
* Controls if this Sprite is rendered or skipped during the core game loop.
|
||||
*/
|
||||
public fillColor: string = 'rgb(255,255,255)';
|
||||
public visible: bool;
|
||||
|
||||
/**
|
||||
* Color of bound when render debug. (see renderDebug) Format is a css color string.
|
||||
* @type {string}
|
||||
*
|
||||
*/
|
||||
public renderDebugColor: string = 'rgba(0,255,0,0.5)';
|
||||
public alive: bool;
|
||||
|
||||
/**
|
||||
* Color of points when render debug. (see renderDebug) Format is a css color string.
|
||||
* @type {string}
|
||||
* The position of the Sprite in world and screen coordinates.
|
||||
*/
|
||||
public renderDebugPointColor: string = 'rgba(255,255,255,1)';
|
||||
public position: Phaser.Components.Position;
|
||||
|
||||
/**
|
||||
* Flip the graphic horizontally? (defaults to false)
|
||||
* @type {boolean}
|
||||
* The texture used to render the Sprite.
|
||||
*/
|
||||
public flipped: bool = false;
|
||||
public texture: Phaser.Components.Texture;
|
||||
|
||||
/**
|
||||
* Load graphic for this sprite. (graphic can be SpriteSheet or Texture)
|
||||
* @param key {string} Key of the graphic you want to load for this sprite.
|
||||
* @param clearAnimations {boolean} If this Sprite has a set of animation data already loaded you can choose to keep or clear it with this boolean
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
* The frame boundary around this Sprite.
|
||||
* For non-animated sprites this matches the loaded texture dimensions.
|
||||
* For animated sprites it will be updated as part of the animation loop, changing to the dimensions of the current animation frame.
|
||||
*/
|
||||
public loadGraphic(key: string, clearAnimations: bool = true): Sprite {
|
||||
public frameBounds: Phaser.Rectangle;
|
||||
|
||||
if (clearAnimations && this.animations.frameData !== null)
|
||||
{
|
||||
this.animations.destroy();
|
||||
}
|
||||
public scale: Phaser.Vec2;
|
||||
public scrollFactor: Phaser.Vec2;
|
||||
|
||||
if (this._game.cache.getImage(key) !== null)
|
||||
{
|
||||
if (this._game.cache.isSpriteSheet(key) == false)
|
||||
{
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this.frameBounds.width = this._texture.width;
|
||||
this.frameBounds.height = this._texture.height;
|
||||
this.collisionMask.width = this._texture.width;
|
||||
this.collisionMask.height = this._texture.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this.animations.loadFrameData(this._game.cache.getFrameData(key));
|
||||
this.collisionMask.width = this.animations.currentFrame.width;
|
||||
this.collisionMask.height = this.animations.currentFrame.height;
|
||||
}
|
||||
|
||||
this._dynamicTexture = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
/**
|
||||
* x value of the object.
|
||||
*/
|
||||
public get x(): number {
|
||||
return this.position.world.x;
|
||||
}
|
||||
|
||||
public set x(value: number) {
|
||||
this.position.world.x = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a DynamicTexture as its texture.
|
||||
* @param texture {DynamicTexture} The texture object to be used by this sprite.
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
* y value of the object.
|
||||
*/
|
||||
public loadDynamicTexture(texture: DynamicTexture): Sprite {
|
||||
|
||||
this._texture = texture;
|
||||
|
||||
this.frameBounds.width = this._texture.width;
|
||||
this.frameBounds.height = this._texture.height;
|
||||
|
||||
this._dynamicTexture = true;
|
||||
|
||||
return this;
|
||||
public get y(): number {
|
||||
return this.position.world.y;
|
||||
}
|
||||
|
||||
public set y(value: number) {
|
||||
this.position.world.y = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function creates a flat colored square image dynamically.
|
||||
* @param width {number} The width of the sprite you want to generate.
|
||||
* @param height {number} The height of the sprite you want to generate.
|
||||
* @param [color] {number} specifies the color of the generated block. (format is 0xAARRGGBB)
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
* z value of the object.
|
||||
*/
|
||||
public makeGraphic(width: number, height: number, color: string = 'rgb(255,255,255)'): Sprite {
|
||||
|
||||
this._texture = null;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.fillColor = color;
|
||||
this._dynamicTexture = false;
|
||||
|
||||
return this;
|
||||
public get z(): number {
|
||||
return this.position.z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this object is visible in a specific camera rectangle.
|
||||
* @param camera {Rectangle} The rectangle you want to check.
|
||||
* @return {boolean} Return true if bounds of this sprite intersects the given rectangle, otherwise return false.
|
||||
*/
|
||||
public inCamera(camera: Rectangle, cameraOffsetX: number, cameraOffsetY: number): bool {
|
||||
|
||||
// Object fixed in place regardless of the camera scrolling? Then it's always visible
|
||||
if (this.scrollFactor.x == 0 && this.scrollFactor.y == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
this._dx = (this.frameBounds.x - camera.x);
|
||||
this._dy = (this.frameBounds.y - camera.y);
|
||||
this._dw = this.frameBounds.width * this.scale.x;
|
||||
this._dh = this.frameBounds.height * this.scale.y;
|
||||
|
||||
return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically called after update() by the game loop, this function just updates animations.
|
||||
*/
|
||||
public postUpdate() {
|
||||
|
||||
this.animations.update();
|
||||
|
||||
super.postUpdate();
|
||||
|
||||
}
|
||||
|
||||
public set frame(value: number) {
|
||||
this.animations.frame = value;
|
||||
}
|
||||
|
||||
public get frame(): number {
|
||||
return this.animations.frame;
|
||||
}
|
||||
|
||||
public set frameName(value: string) {
|
||||
this.animations.frameName = value;
|
||||
}
|
||||
|
||||
public get frameName(): string {
|
||||
return this.animations.frameName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this sprite to specific camera. Called by game loop after update().
|
||||
* @param camera {Camera} Camera this sprite will be rendered to.
|
||||
* @cameraOffsetX {number} X offset to the camera.
|
||||
* @cameraOffsetY {number} Y offset to the camera.
|
||||
* @return {boolean} Return false if not rendered, otherwise return true.
|
||||
*/
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool {
|
||||
|
||||
// Render checks
|
||||
if (this.visible == false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView, cameraOffsetX, cameraOffsetY) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._sx = 0;
|
||||
this._sy = 0;
|
||||
this._sw = this.frameBounds.width;
|
||||
this._sh = this.frameBounds.height;
|
||||
|
||||
this._dx = (cameraOffsetX * this.scrollFactor.x) + this.frameBounds.topLeft.x - (camera.worldView.x * this.scrollFactor.x);
|
||||
this._dy = (cameraOffsetY * this.scrollFactor.y) + this.frameBounds.topLeft.y - (camera.worldView.y * this.scrollFactor.y);
|
||||
this._dw = this.frameBounds.width * this.scale.x;
|
||||
this._dh = this.frameBounds.height * this.scale.y;
|
||||
|
||||
if (this.align == GameObject.ALIGN_TOP_CENTER)
|
||||
{
|
||||
this._dx -= this.frameBounds.halfWidth * this.scale.x;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_TOP_RIGHT)
|
||||
{
|
||||
this._dx -= this.frameBounds.width * this.scale.x;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_CENTER_LEFT)
|
||||
{
|
||||
this._dy -= this.frameBounds.halfHeight * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_CENTER)
|
||||
{
|
||||
this._dx -= this.frameBounds.halfWidth * this.scale.x;
|
||||
this._dy -= this.frameBounds.halfHeight * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_CENTER_RIGHT)
|
||||
{
|
||||
this._dx -= this.frameBounds.width * this.scale.x;
|
||||
this._dy -= this.frameBounds.halfHeight * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_BOTTOM_LEFT)
|
||||
{
|
||||
this._dy -= this.frameBounds.height * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_BOTTOM_CENTER)
|
||||
{
|
||||
this._dx -= this.frameBounds.halfWidth * this.scale.x;
|
||||
this._dy -= this.frameBounds.height * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_BOTTOM_RIGHT)
|
||||
{
|
||||
this._dx -= this.frameBounds.width * this.scale.x;
|
||||
this._dy -= this.frameBounds.height * this.scale.y;
|
||||
}
|
||||
|
||||
if (this._dynamicTexture == false && this.animations.currentFrame !== null)
|
||||
{
|
||||
this._sx = this.animations.currentFrame.x;
|
||||
this._sy = this.animations.currentFrame.y;
|
||||
|
||||
if (this.animations.currentFrame.trimmed)
|
||||
{
|
||||
this._dx += this.animations.currentFrame.spriteSourceSizeX;
|
||||
this._dy += this.animations.currentFrame.spriteSourceSizeY;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply camera difference
|
||||
if (this.scrollFactor.x !== 1 || this.scrollFactor.y !== 1)
|
||||
{
|
||||
//this._dx -= (camera.worldView.x * this.scrollFactor.x);
|
||||
//this._dy -= (camera.worldView.y * this.scrollFactor.y);
|
||||
}
|
||||
|
||||
// Rotation - needs to work from origin point really, but for now from center
|
||||
if (this.angle !== 0 || this.rotationOffset !== 0 || this.flipped == true)
|
||||
{
|
||||
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.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180));
|
||||
}
|
||||
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
|
||||
if (this.flipped == true)
|
||||
{
|
||||
this.context.scale(-1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this._sx = Math.round(this._sx);
|
||||
this._sy = Math.round(this._sy);
|
||||
this._sw = Math.round(this._sw);
|
||||
this._sh = Math.round(this._sh);
|
||||
this._dx = Math.round(this._dx);
|
||||
this._dy = Math.round(this._dy);
|
||||
this._dw = Math.round(this._dw);
|
||||
this._dh = Math.round(this._dh);
|
||||
|
||||
if (this._texture != null)
|
||||
{
|
||||
if (this._dynamicTexture)
|
||||
{
|
||||
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
|
||||
this._sh, // Source Height
|
||||
this._dx, // Destination X (where on the canvas it'll be drawn)
|
||||
this._dy, // Destination Y
|
||||
this._dw, // Destination Width (always same as Source Width unless scaled)
|
||||
this._dh // Destination Height (always same as Source Height unless scaled)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.context.drawImage(
|
||||
this._texture, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._sw, // Source Width
|
||||
this._sh, // Source Height
|
||||
this._dx, // Destination X (where on the canvas it'll be drawn)
|
||||
this._dy, // Destination Y
|
||||
this._dw, // Destination Width (always same as Source Width unless scaled)
|
||||
this._dh // Destination Height (always same as Source Height unless scaled)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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.context.translate(0, 0);
|
||||
this.context.restore();
|
||||
}
|
||||
|
||||
if (this.renderDebug)
|
||||
{
|
||||
this.renderBounds(camera, cameraOffsetX, cameraOffsetY);
|
||||
//this.collisionMask.render(camera, cameraOffsetX, cameraOffsetY);
|
||||
}
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the bounding box around this Sprite and the contact points. Useful for visually debugging.
|
||||
* @param camera {Camera} Camera the bound will be rendered to.
|
||||
* @param cameraOffsetX {number} X offset of bound to the camera.
|
||||
* @param cameraOffsetY {number} Y offset of bound to the camera.
|
||||
*/
|
||||
private renderBounds(camera:Camera, cameraOffsetX:number, cameraOffsetY:number) {
|
||||
|
||||
this._dx = cameraOffsetX + (this.frameBounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.frameBounds.topLeft.y - camera.worldView.y);
|
||||
|
||||
this.context.fillStyle = this.renderDebugColor;
|
||||
this.context.fillRect(this._dx, this._dy, this.frameBounds.width, this.frameBounds.height);
|
||||
|
||||
//this.context.fillStyle = this.renderDebugPointColor;
|
||||
|
||||
//var hw = this.frameBounds.halfWidth * this.scale.x;
|
||||
//var hh = this.frameBounds.halfHeight * this.scale.y;
|
||||
//var sw = (this.frameBounds.width * this.scale.x) - 1;
|
||||
//var sh = (this.frameBounds.height * this.scale.y) - 1;
|
||||
|
||||
//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
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render debug infos. (including name, bounds info, position and some other properties)
|
||||
* @param x {number} X position of the debug info to be rendered.
|
||||
* @param y {number} Y position of the debug info to be rendered.
|
||||
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
|
||||
*/
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillText('Sprite: ' + this.name + ' (' + this.frameBounds.width + ' x ' + this.frameBounds.height + ')', x, y);
|
||||
this.context.fillText('x: ' + this.frameBounds.x.toFixed(1) + ' y: ' + this.frameBounds.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);
|
||||
|
||||
public set z(value: number) {
|
||||
this.position.z = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vendored
-31
@@ -1,31 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="GameObject.d.ts" />
|
||||
/// <reference path="../system/TilemapLayer.d.ts" />
|
||||
/// <reference path="../system/Tile.d.ts" />
|
||||
module Phaser {
|
||||
class Tilemap extends GameObject {
|
||||
constructor(game: Game, key: string, mapData: string, format: number, resizeWorld?: bool, tileWidth?: number, tileHeight?: number);
|
||||
static FORMAT_CSV: number;
|
||||
static FORMAT_TILED_JSON: number;
|
||||
public tiles: Tile[];
|
||||
public layers: TilemapLayer[];
|
||||
public currentLayer: TilemapLayer;
|
||||
public collisionLayer: TilemapLayer;
|
||||
public mapFormat: number;
|
||||
public update(): void;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
|
||||
private parseCSV(data, key, tileWidth, tileHeight);
|
||||
private parseTiledJSON(data, key);
|
||||
private generateTiles(qty);
|
||||
public widthInPixels : number;
|
||||
public heightInPixels : number;
|
||||
public setCollisionRange(start: number, end: number, collision?: number, resetCollisions?: bool): void;
|
||||
public setCollisionByIndex(values: number[], collision?: number, resetCollisions?: bool): void;
|
||||
public getTile(x: number, y: number, layer?: number): Tile;
|
||||
public getTileFromWorldXY(x: number, y: number, layer?: number): Tile;
|
||||
public getTileFromInputXY(layer?: number): Tile;
|
||||
public getTileOverlaps(object: GameObject): bool;
|
||||
public collide(objectOrGroup?, callback?): bool;
|
||||
public collideGameObject(object: GameObject): bool;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="GameObject.ts" />
|
||||
/// <reference path="../system/TilemapLayer.ts" />
|
||||
/// <reference path="../system/Tile.ts" />
|
||||
/// <reference path="../components/TilemapLayer.ts" />
|
||||
/// <reference path="../components/Tile.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Tilemap
|
||||
@@ -12,7 +11,7 @@
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Tilemap extends GameObject {
|
||||
export class Tilemap {
|
||||
|
||||
/**
|
||||
* Tilemap constructor
|
||||
@@ -28,7 +27,7 @@ module Phaser {
|
||||
*/
|
||||
constructor(game: Game, key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0) {
|
||||
|
||||
super(game);
|
||||
//super(game);
|
||||
|
||||
this.isGroup = false;
|
||||
|
||||
|
||||
Vendored
-34
@@ -1,34 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Circle {
|
||||
constructor(x?: number, y?: number, diameter?: number);
|
||||
private _diameter;
|
||||
private _radius;
|
||||
public x: number;
|
||||
public y: number;
|
||||
public diameter : number;
|
||||
public radius : number;
|
||||
public circumference(): number;
|
||||
public bottom : number;
|
||||
public left : number;
|
||||
public right : number;
|
||||
public top : number;
|
||||
public area : number;
|
||||
public isEmpty : bool;
|
||||
public intersectCircleLine(line: Line): bool;
|
||||
public clone(output?: Circle): Circle;
|
||||
public contains(x: number, y: number): bool;
|
||||
public containsPoint(point: Point): bool;
|
||||
public containsCircle(circle: Circle): bool;
|
||||
public copyFrom(source: Circle): Circle;
|
||||
public copyTo(target: Circle): Circle;
|
||||
public distanceTo(target: any, round?: bool): number;
|
||||
public equals(toCompare: Circle): bool;
|
||||
public intersects(toIntersect: Circle): bool;
|
||||
public circumferencePoint(angle: number, asDegrees?: bool, output?: Point): Point;
|
||||
public offset(dx: number, dy: number): Circle;
|
||||
public offsetPoint(point: Point): Circle;
|
||||
public setTo(x: number, y: number, diameter: number): Circle;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class IntersectResult {
|
||||
public result: bool;
|
||||
public x: number;
|
||||
public y: number;
|
||||
public x1: number;
|
||||
public y1: number;
|
||||
public x2: number;
|
||||
public y2: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
public setTo(x1: number, y1: number, x2?: number, y2?: number, width?: number, height?: number): void;
|
||||
}
|
||||
}
|
||||
Vendored
-27
@@ -1,27 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Line {
|
||||
constructor(x1?: number, y1?: number, x2?: number, y2?: number);
|
||||
public x1: number;
|
||||
public y1: number;
|
||||
public x2: number;
|
||||
public y2: number;
|
||||
public clone(output?: Line): Line;
|
||||
public copyFrom(source: Line): Line;
|
||||
public copyTo(target: Line): Line;
|
||||
public setTo(x1?: number, y1?: number, x2?: number, y2?: number): Line;
|
||||
public width : number;
|
||||
public height : number;
|
||||
public length : number;
|
||||
public getY(x: number): number;
|
||||
public angle : number;
|
||||
public slope : number;
|
||||
public perpSlope : number;
|
||||
public yIntercept : number;
|
||||
public isPointOnLine(x: number, y: number): bool;
|
||||
public isPointOnLineSegment(x: number, y: number): bool;
|
||||
public intersectLineLine(line): any;
|
||||
public perp(x: number, y: number, output?: Line): Line;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class MicroPoint {
|
||||
constructor(x?: number, y?: number, parent?: any);
|
||||
private _x;
|
||||
private _y;
|
||||
public parent: any;
|
||||
public x : number;
|
||||
public y : number;
|
||||
public copyFrom(source: any): MicroPoint;
|
||||
public copyTo(target: any): MicroPoint;
|
||||
public setTo(x: number, y: number, callParent?: bool): MicroPoint;
|
||||
public equals(toCompare): bool;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-28
@@ -1,28 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Point {
|
||||
constructor(x?: number, y?: number);
|
||||
public x: number;
|
||||
public y: number;
|
||||
public add(toAdd: Point, output?: Point): Point;
|
||||
public addTo(x?: number, y?: number): Point;
|
||||
public subtractFrom(x?: number, y?: number): Point;
|
||||
public invert(): Point;
|
||||
public clamp(min: number, max: number): Point;
|
||||
public clampX(min: number, max: number): Point;
|
||||
public clampY(min: number, max: number): Point;
|
||||
public clone(output?: Point): Point;
|
||||
public copyFrom(source: Point): Point;
|
||||
public copyTo(target: Point): Point;
|
||||
public distanceTo(target: Point, round?: bool): number;
|
||||
static distanceBetween(pointA: Point, pointB: Point, round?: bool): number;
|
||||
public distanceCompare(target: Point, distance: number): bool;
|
||||
public equals(toCompare: Point): bool;
|
||||
public interpolate(pointA, pointB, f): void;
|
||||
public offset(dx: number, dy: number): Point;
|
||||
public polar(length, angle): void;
|
||||
public setTo(x: number, y: number): Point;
|
||||
public subtract(point: Point, output?: Point): Point;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,10 @@ module Phaser {
|
||||
* A *convex* clockwise polygon
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param {Vector2} pos A vector representing the origin of the polygon (all other points are relative to this one)
|
||||
* @param {Array.<Vector2>} points An Array of vectors representing the points in the polygon, in clockwise order.
|
||||
* @param {Vec2} pos A vector representing the origin of the polygon (all other points are relative to this one)
|
||||
* @param {Array.<Vec2>} points An Array of vectors representing the points in the polygon, in clockwise order.
|
||||
**/
|
||||
constructor(pos?: Vector2 = new Vector2, points?: Vector2[] = [], parent?:any = null) {
|
||||
constructor(pos?: Vec2 = new Vec2, points?: Vec2[] = [], parent?:any = null) {
|
||||
|
||||
this.pos = pos;
|
||||
this.points = points;
|
||||
@@ -26,10 +26,10 @@ module Phaser {
|
||||
}
|
||||
|
||||
public parent: any;
|
||||
public pos: Vector2;
|
||||
public points: Vector2[];
|
||||
public edges: Vector2[];
|
||||
public normals: Vector2[];
|
||||
public pos: Vec2;
|
||||
public points: Vec2[];
|
||||
public edges: Vec2[];
|
||||
public normals: Vec2[];
|
||||
|
||||
/**
|
||||
* Recalculate the edges and normals of the polygon. This
|
||||
@@ -48,8 +48,8 @@ module Phaser {
|
||||
{
|
||||
var p1 = points[i];
|
||||
var p2 = i < len - 1 ? points[i + 1] : points[0];
|
||||
var e = new Vector2().copyFrom(p2).sub(p1);
|
||||
var n = new Vector2().copyFrom(e).perp().normalize();
|
||||
var e = new Vec2().copyFrom(p2).sub(p1);
|
||||
var n = new Vec2().copyFrom(e).perp().normalize();
|
||||
this.edges.push(e);
|
||||
this.normals.push(n);
|
||||
}
|
||||
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Quad {
|
||||
constructor(x?: number, y?: number, width?: number, height?: number);
|
||||
public x: number;
|
||||
public y: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
public setTo(x: number, y: number, width: number, height: number): Quad;
|
||||
public left : number;
|
||||
public right : number;
|
||||
public top : number;
|
||||
public bottom : number;
|
||||
public halfWidth : number;
|
||||
public halfHeight : number;
|
||||
public intersects(q, t?: number): bool;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-57
@@ -1,57 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="MicroPoint.d.ts" />
|
||||
module Phaser {
|
||||
class Rectangle {
|
||||
constructor(x?: number, y?: number, width?: number, height?: number);
|
||||
private _tempX;
|
||||
private _tempY;
|
||||
private _tempWidth;
|
||||
private _tempHeight;
|
||||
public x : number;
|
||||
public y : number;
|
||||
public topLeft: MicroPoint;
|
||||
public topCenter: MicroPoint;
|
||||
public topRight: MicroPoint;
|
||||
public leftCenter: MicroPoint;
|
||||
public center: MicroPoint;
|
||||
public rightCenter: MicroPoint;
|
||||
public bottomLeft: MicroPoint;
|
||||
public bottomCenter: MicroPoint;
|
||||
public bottomRight: MicroPoint;
|
||||
private _width;
|
||||
private _height;
|
||||
private _halfWidth;
|
||||
private _halfHeight;
|
||||
public length: number;
|
||||
public updateBounds(): void;
|
||||
public width : number;
|
||||
public height : number;
|
||||
public halfWidth : number;
|
||||
public halfHeight : number;
|
||||
public bottom : number;
|
||||
public left : number;
|
||||
public right : number;
|
||||
public size(output?: Point): Point;
|
||||
public volume : number;
|
||||
public perimeter : number;
|
||||
public top : number;
|
||||
public clone(output?: Rectangle): Rectangle;
|
||||
public contains(x: number, y: number): bool;
|
||||
public containsPoint(point: any): bool;
|
||||
public containsRect(rect: Rectangle): bool;
|
||||
public copyFrom(source: Rectangle): Rectangle;
|
||||
public copyTo(target: Rectangle): Rectangle;
|
||||
public equals(toCompare: Rectangle): bool;
|
||||
public inflate(dx: number, dy: number): Rectangle;
|
||||
public inflatePoint(point: Point): Rectangle;
|
||||
public intersection(toIntersect: Rectangle, output?: Rectangle): Rectangle;
|
||||
public intersects(r2: Rectangle, t?: number): bool;
|
||||
public isEmpty : bool;
|
||||
public offset(dx: number, dy: number): Rectangle;
|
||||
public offsetPoint(point: Point): Rectangle;
|
||||
public setEmpty(): Rectangle;
|
||||
public setTo(x: number, y: number, width: number, height: number): Rectangle;
|
||||
public union(toUnion: Rectangle, output?: Rectangle): Rectangle;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,8 @@ module Phaser {
|
||||
|
||||
this.a = null;
|
||||
this.b = null;
|
||||
this.overlapN = new Vector2;
|
||||
this.overlapV = new Vector2;
|
||||
this.overlapN = new Vec2;
|
||||
this.overlapV = new Vec2;
|
||||
|
||||
this.clear();
|
||||
|
||||
@@ -43,13 +43,13 @@ module Phaser {
|
||||
/**
|
||||
* The shortest colliding axis (unit-vector)
|
||||
*/
|
||||
public overlapN: Vector2;
|
||||
public overlapN: Vec2;
|
||||
|
||||
/**
|
||||
* The overlap vector (i.e. overlapN.scale(overlap, overlap)).
|
||||
* If this vector is subtracted from the position of `a`, `a` and `b` will no longer be colliding.
|
||||
*/
|
||||
public overlapV: Vector2;
|
||||
public overlapV: Vec2;
|
||||
|
||||
/**
|
||||
* Whether the first object is completely inside the second.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Pointer.ts" />
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../Signal.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../Signal.ts" />
|
||||
/// <reference path="Pointer.ts" />
|
||||
/// <reference path="MSPointer.ts" />
|
||||
/// <reference path="Gestures.ts" />
|
||||
/// <reference path="../utils/PointUtils.ts" />
|
||||
/// <reference path="../math/Vec2Utils.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Input
|
||||
@@ -37,7 +39,7 @@ module Phaser {
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
|
||||
this.position = new Vector2;
|
||||
this.position = new Vec2;
|
||||
this.circle = new Circle(0, 0, 44);
|
||||
|
||||
this.currentPointers = 0;
|
||||
@@ -112,9 +114,9 @@ module Phaser {
|
||||
/**
|
||||
* A vector object representing the current position of the Pointer.
|
||||
* @property vector
|
||||
* @type {Vector2}
|
||||
* @type {Vec2}
|
||||
**/
|
||||
public position: Vector2 = null;
|
||||
public position: Vec2 = null;
|
||||
|
||||
/**
|
||||
* A Circle object centered on the x/y screen coordinates of the Input.
|
||||
@@ -855,7 +857,7 @@ module Phaser {
|
||||
* @param {Pointer} pointer2
|
||||
**/
|
||||
public getDistance(pointer1: Pointer, pointer2: Pointer): number {
|
||||
return pointer1.position.distance(pointer2.position);
|
||||
return Vec2Utils.distance(pointer1.position, pointer2.position);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -865,7 +867,7 @@ module Phaser {
|
||||
* @param {Pointer} pointer2
|
||||
**/
|
||||
public getAngle(pointer1: Pointer, pointer2: Pointer): number {
|
||||
return pointer1.position.angle(pointer2.position);
|
||||
return Vec2Utils.angle(pointer1.position, pointer2.position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Keyboard
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Pointer.ts" />
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Mouse
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../geom/Vector2.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../core/Vec2.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Pointer
|
||||
@@ -22,8 +22,8 @@ module Phaser {
|
||||
|
||||
this.id = id;
|
||||
this.active = false;
|
||||
this.position = new Vector2;
|
||||
this.positionDown = new Vector2;
|
||||
this.position = new Vec2;
|
||||
this.positionDown = new Vec2;
|
||||
this.circle = new Circle(0, 0, 44);
|
||||
|
||||
if (id == 0)
|
||||
@@ -91,16 +91,16 @@ module Phaser {
|
||||
/**
|
||||
* A Vector object containing the initial position when the Pointer was engaged with the screen.
|
||||
* @property positionDown
|
||||
* @type {Vector2}
|
||||
* @type {Vec2}
|
||||
**/
|
||||
public positionDown: Vector2 = null;
|
||||
public positionDown: Vec2 = null;
|
||||
|
||||
/**
|
||||
* A Vector object containing the current position of the Pointer on the screen.
|
||||
* @property position
|
||||
* @type {Vector2}
|
||||
* @type {Vec2}
|
||||
**/
|
||||
public position: Vector2 = null;
|
||||
public position: Vec2 = null;
|
||||
|
||||
/**
|
||||
* A Circle object centered on the x/y screen coordinates of the Pointer.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Pointer.ts" />
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - AnimationLoader
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - GameMath
|
||||
@@ -1,457 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Vector2
|
||||
*
|
||||
* A two dimensional vector.
|
||||
* Contains methods and ideas from verlet-js by Sub Protocol, SAT.js by Jim Riecken and N by Metanet Software. Brandon Jones, Colin MacKenzie IV
|
||||
*/
|
||||
|
||||
module Phaser.Math {
|
||||
|
||||
export class Vec2 {
|
||||
|
||||
/**
|
||||
* Creates a new Vector2 object.
|
||||
* @class Vector2
|
||||
* @constructor
|
||||
* @param {Number} x The x position of the vector
|
||||
* @param {Number} y The y position of the vector
|
||||
* @return {Vector2} This object
|
||||
**/
|
||||
constructor(x: number = 0, y: number = 0) {
|
||||
|
||||
//var GLMAT_ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
}
|
||||
|
||||
public x: number;
|
||||
public y: number;
|
||||
|
||||
public setTo(x: number, y: number): Vector2 {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add this vector to the given one and return the result.
|
||||
*
|
||||
* @param {Vector2} v The other Vector.
|
||||
* @param {Vector2} The output Vector.
|
||||
* @return {Vector2} The new Vector
|
||||
*/
|
||||
public add(v: Vector2, output?:Vector2 = new Vector2): Vector2 {
|
||||
return output.setTo(this.x + v.x, this.y + v.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract this vector to the given one and return the result.
|
||||
*
|
||||
* @param {Vector2} v The other Vector.
|
||||
* @param {Vector2} The output Vector.
|
||||
* @return {Vector2} The new Vector
|
||||
*/
|
||||
public sub(v: Vector2, output?:Vector2 = new Vector2): Vector2 {
|
||||
return output.setTo(this.x - v.x, this.y - v.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector with the given one and return the result.
|
||||
*
|
||||
* @param {Vector2} v The other Vector.
|
||||
* @param {Vector2} The output Vector.
|
||||
* @return {Vector2} The new Vector
|
||||
*/
|
||||
public mul(v: Vector2, output?:Vector2 = new Vector2): Vector2 {
|
||||
return output.setTo(this.x * v.x, this.y * v.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by the given one and return the result.
|
||||
*
|
||||
* @param {Vector2} v The other Vector.
|
||||
* @param {Vector2} The output Vector.
|
||||
* @return {Vector2} The new Vector
|
||||
*/
|
||||
public div(v: Vector2, output?:Vector2 = new Vector2): Vector2 {
|
||||
return output.setTo(this.x / v.x, this.y / v.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale this vector by the given values and return the result.
|
||||
*
|
||||
* @param {number} x The scaling factor in the x direction.
|
||||
* @param {?number=} y The scaling factor in the y direction. If this
|
||||
* is not specified, the x scaling factor will be used.
|
||||
* @return {Vector} The new Vector
|
||||
*/
|
||||
public scale(x: number, y?:number = null, output?:Vector2 = new Vector2): Vector2 {
|
||||
|
||||
if (y === null)
|
||||
{
|
||||
y = x;
|
||||
}
|
||||
|
||||
return output.setTo(this.x * x, this.y * y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this vector by 90 degrees
|
||||
*
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public perp(output?: Vector2 = this): Vector2 {
|
||||
var x = this.x;
|
||||
return output.setTo(this.y, -x);
|
||||
}
|
||||
|
||||
// Same as copyFrom, used by VerletManager
|
||||
public mutableSet(v: Vector2): Vector2 {
|
||||
this.x = v.x;
|
||||
this.y = v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another vector to this one.
|
||||
*
|
||||
* @param {Vector} other The other Vector.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public mutableAdd(v: Vector2): Vector2 {
|
||||
this.x += v.x;
|
||||
this.y += v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract another vector from this one.
|
||||
*
|
||||
* @param {Vector} other The other Vector.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public mutableSub(v: Vector2): Vector2 {
|
||||
this.x -= v.x;
|
||||
this.y -= v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply another vector with this one.
|
||||
*
|
||||
* @param {Vector} other The other Vector.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public mutableMul(v: Vector2): Vector2 {
|
||||
this.x *= v.x;
|
||||
this.y *= v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by another one.
|
||||
*
|
||||
* @param {Vector} other The other Vector.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public mutableDiv(v: Vector2): Vector2 {
|
||||
this.x /= v.x;
|
||||
this.y /= v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale this vector.
|
||||
*
|
||||
* @param {number} x The scaling factor in the x direction.
|
||||
* @param {?number=} y The scaling factor in the y direction. If this
|
||||
* is not specified, the x scaling factor will be used.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public mutableScale(x: number, y?:number): Vector2 {
|
||||
this.x *= x;
|
||||
this.y *= y || x;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector by the given scalar.
|
||||
*
|
||||
* @param {number} scalar
|
||||
* @return {Vector2} This for chaining.
|
||||
*/
|
||||
public mutableMultiplyByScalar(scalar: number): Vector2 {
|
||||
this.x *= scalar;
|
||||
this.y *= scalar;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by the given scalar.
|
||||
*
|
||||
* @param {number} scalar
|
||||
* @return {Vector2} This for chaining.
|
||||
*/
|
||||
public mutableDivideByScalar(scalar: number): Vector2 {
|
||||
this.x /= scalar;
|
||||
this.y /= scalar;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse this vector.
|
||||
*
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public reverse(): Vector2 {
|
||||
this.x = -this.x;
|
||||
this.y = -this.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public edge(v: Vector2, output?: Vector2 = new Vector2): Vector2 {
|
||||
return this.sub(v, output);
|
||||
}
|
||||
|
||||
public equals(v: Vector2): bool {
|
||||
return this.x == v.x && this.y == v.y;
|
||||
}
|
||||
|
||||
public epsilonEquals(v: Vector2, epsilon:number): bool {
|
||||
return Math.abs(this.x - v.x) <= epsilon && Math.abs(this.y - v.y) <= epsilon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of this vector.
|
||||
*
|
||||
* @return {number} The length of this vector.
|
||||
*/
|
||||
public length(): number {
|
||||
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length^2 of this vector.
|
||||
*
|
||||
* @return {number} The length^2 of this vector.
|
||||
*/
|
||||
public length2(): number {
|
||||
return (this.x * this.x) + (this.y * this.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance between this vector and the given vector.
|
||||
*
|
||||
* @return {Vector2} v The vector to check
|
||||
*/
|
||||
public distance(v: Vector2): number {
|
||||
return Math.sqrt(this.distance2(v));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance^2 between this vector and the given vector.
|
||||
*
|
||||
* @return {Vector2} v The vector to check
|
||||
*/
|
||||
public distance2(v: Vector2): number {
|
||||
return ((v.x - this.x) * (v.x - this.x)) + ((v.y - this.y) * (v.y - this.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Project this vector on to another vector.
|
||||
*
|
||||
* @param {Vector} other The vector to project onto.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public project(other: Vector2): Vector2 {
|
||||
|
||||
var amt = this.dot(other) / other.length2();
|
||||
|
||||
if (amt != 0)
|
||||
{
|
||||
this.x = amt * other.x;
|
||||
this.y = amt * other.y;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Project this vector onto a vector of unit length.
|
||||
*
|
||||
* @param {Vector} other The unit vector to project onto.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public projectN(other: Vector2): Vector2 {
|
||||
|
||||
var amt = this.dot(other);
|
||||
|
||||
if (amt != 0)
|
||||
{
|
||||
this.x = amt * other.x;
|
||||
this.y = amt * other.y;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reflect this vector on an arbitrary axis.
|
||||
*
|
||||
* @param {Vector} axis The vector representing the axis.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public reflect(axis): Vector2 {
|
||||
|
||||
var x = this.x;
|
||||
var y = this.y;
|
||||
this.project(axis).scale(2);
|
||||
this.x -= x;
|
||||
this.y -= y;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reflect this vector on an arbitrary axis (represented by a unit vector)
|
||||
*
|
||||
* @param {Vector} axis The unit vector representing the axis.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public reflectN(axis): Vector2 {
|
||||
|
||||
var x = this.x;
|
||||
var y = this.y;
|
||||
this.projectN(axis).scale(2);
|
||||
this.x -= x;
|
||||
this.y -= y;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public getProjectionMagnitude(v: Vector2): number {
|
||||
|
||||
var den = v.dot(v);
|
||||
|
||||
if (den == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.abs(this.dot(v) / den);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public direction(output?: Vector2 = new Vector2): Vector2 {
|
||||
|
||||
output.copyFrom(this);
|
||||
return this.normalize(output);
|
||||
|
||||
}
|
||||
|
||||
public normalRightHand(output?: Vector2 = this): Vector2 {
|
||||
return output.setTo(this.y * -1, this.x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize (make unit length) this vector.
|
||||
*
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public normalize(output?: Vector2 = this): Vector2 {
|
||||
|
||||
var m = this.length();
|
||||
|
||||
if (m != 0)
|
||||
{
|
||||
output.setTo(this.x / m, this.y / m);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public getMagnitude(): number {
|
||||
return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dot product of this vector against another.
|
||||
*
|
||||
* @param {Vector} other The vector to dot this one against.
|
||||
* @return {number} The dot product.
|
||||
*/
|
||||
public dot(v: Vector2): number {
|
||||
return ((this.x * v.x) + (this.y * v.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cross product of this vector against another.
|
||||
*
|
||||
* @param {Vector} other The vector to cross this one against.
|
||||
* @return {number} The cross product.
|
||||
*/
|
||||
public cross(v: Vector2): number {
|
||||
return ((this.x * v.y) - (this.y * v.x));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the angle between this vector and the given vector.
|
||||
*
|
||||
* @return {Vector2} v The vector to check
|
||||
*/
|
||||
public angle(v: Vector2): number {
|
||||
return Math.atan2(this.x * v.y - this.y * v.x, this.x * v.x + this.y * v.y);
|
||||
}
|
||||
|
||||
public angle2(vLeft: Vector2, vRight: Vector2): number {
|
||||
return vLeft.sub(this).angle(vRight.sub(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this vector around the origin to the given angle (theta) and return the result in a new Vector
|
||||
*
|
||||
* @return {Vector2} v The vector to check
|
||||
*/
|
||||
public rotate(origin, theta, output?: Vector2 = new Vector2): Vector2 {
|
||||
var x = this.x - origin.x;
|
||||
var y = this.y - origin.y;
|
||||
return output.setTo(x * Math.cos(theta) - y * Math.sin(theta) + origin.x, x * Math.sin(theta) + y * Math.cos(theta) + origin.y);
|
||||
}
|
||||
|
||||
public clone(output?: Vector2 = new Vector2): Vector2 {
|
||||
return output.setTo(this.x, this.y);
|
||||
}
|
||||
|
||||
public copyFrom(v: Vector2): Vector2 {
|
||||
this.x = v.x;
|
||||
this.y = v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public copyTo(v: Vector2): Vector2 {
|
||||
return v.setTo(this.x, this.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the object.
|
||||
**/
|
||||
public toString(): string {
|
||||
return "[{Vector2 (x=" + this.x + " y=" + this.y + ")}]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
-19
@@ -1,22 +1,4 @@
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
Phaser.VERSION = 'Phaser version 0.9.6';
|
||||
Phaser.Point = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
|
||||
Phaser.Vec2 = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
|
||||
Phaser.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
|
||||
})(Phaser || (Phaser = {}));
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (Geom2) {
|
||||
var Point = (function () {
|
||||
function Point() { }
|
||||
Point.prototype.add = function (a, b) {
|
||||
a[0] = b[0];
|
||||
return a;
|
||||
};
|
||||
return Point;
|
||||
})();
|
||||
Geom2.Point = Point;
|
||||
})(Phaser.Geom2 || (Phaser.Geom2 = {}));
|
||||
var Geom2 = Phaser.Geom2;
|
||||
Phaser.VERSION = 'Phaser version 1.0.0';
|
||||
})(Phaser || (Phaser = {}));
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../RenderManager.ts" />
|
||||
/// <reference path="../gameobjects/Sprite.ts" />
|
||||
/// <reference path="../cameras/Camera.ts" />
|
||||
/// <reference path="IRenderer.ts" />
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class CanvasRenderer implements Phaser.IRenderer {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
// local rendering related temp vars to help avoid gc spikes with var creation
|
||||
private _sx: number = 0;
|
||||
private _sy: number = 0;
|
||||
private _sw: number = 0;
|
||||
private _sh: number = 0;
|
||||
private _dx: number = 0;
|
||||
private _dy: number = 0;
|
||||
private _dw: number = 0;
|
||||
private _dh: number = 0;
|
||||
|
||||
private _cameraList;
|
||||
private _camera: Camera;
|
||||
private _groupLength: number;
|
||||
|
||||
public render() {
|
||||
|
||||
// Get a list of all the active cameras
|
||||
|
||||
this._cameraList = this._game.world.getAllCameras();
|
||||
|
||||
// Then iterate through world.group on them all (where not blacklisted, etc)
|
||||
for (var c = 0; c < this._cameraList.length; c++)
|
||||
{
|
||||
this._camera = this._cameraList[c];
|
||||
|
||||
this._camera.preRender();
|
||||
|
||||
this._game.world.group.render(this._camera);
|
||||
|
||||
this._camera.postRender();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this sprite to specific camera. Called by game loop after update().
|
||||
* @param camera {Camera} Camera this sprite will be rendered to.
|
||||
* @return {boolean} Return false if not rendered, otherwise return true.
|
||||
*/
|
||||
public renderSprite(camera: Camera, sprite: Sprite): bool {
|
||||
|
||||
// Render checks (needs inCamera check added)
|
||||
if (sprite.scale.x == 0 || sprite.scale.y == 0 || sprite.texture.alpha < 0.1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Alpha
|
||||
if (sprite.texture.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = sprite.texture.context.globalAlpha;
|
||||
sprite.texture.context.globalAlpha = sprite.texture.alpha;
|
||||
}
|
||||
|
||||
this._sx = 0;
|
||||
this._sy = 0;
|
||||
this._sw = sprite.frameBounds.width;
|
||||
this._sh = sprite.frameBounds.height;
|
||||
|
||||
this._dx = (camera.scaledX * sprite.scrollFactor.x) + sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
|
||||
this._dy = (camera.scaledY * sprite.scrollFactor.y) + sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
|
||||
this._dw = sprite.frameBounds.width * sprite.scale.x;
|
||||
this._dh = sprite.frameBounds.height * sprite.scale.y;
|
||||
|
||||
/*
|
||||
if (this._dynamicTexture == false && this.animations.currentFrame !== null)
|
||||
{
|
||||
this._sx = this.animations.currentFrame.x;
|
||||
this._sy = this.animations.currentFrame.y;
|
||||
|
||||
if (this.animations.currentFrame.trimmed)
|
||||
{
|
||||
this._dx += this.animations.currentFrame.spriteSourceSizeX;
|
||||
this._dy += this.animations.currentFrame.spriteSourceSizeY;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Apply camera difference
|
||||
if (sprite.scrollFactor.x !== 1 || sprite.scrollFactor.y !== 1)
|
||||
{
|
||||
//this._dx -= (camera.worldView.x * this.scrollFactor.x);
|
||||
//this._dy -= (camera.worldView.y * this.scrollFactor.y);
|
||||
}
|
||||
|
||||
// Rotation and Flipped
|
||||
if (sprite.position.rotation !== 0 || sprite.position.rotationOffset !== 0 || sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
{
|
||||
sprite.texture.context.save();
|
||||
sprite.texture.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
|
||||
if (sprite.texture.renderRotation == true && (sprite.position.rotation !== 0 || sprite.position.rotationOffset !== 0))
|
||||
{
|
||||
// Apply point of rotation here
|
||||
sprite.texture.context.rotate((sprite.position.rotationOffset + sprite.position.rotation) * (Math.PI / 180));
|
||||
}
|
||||
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
|
||||
if (sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
{
|
||||
if (sprite.texture.flippedX)
|
||||
{
|
||||
sprite.texture.context.scale(-1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._sx = Math.round(this._sx);
|
||||
this._sy = Math.round(this._sy);
|
||||
this._sw = Math.round(this._sw);
|
||||
this._sh = Math.round(this._sh);
|
||||
this._dx = Math.round(this._dx);
|
||||
this._dy = Math.round(this._dy);
|
||||
this._dw = Math.round(this._dw);
|
||||
this._dh = Math.round(this._dh);
|
||||
|
||||
//if (this._texture != null)
|
||||
//{
|
||||
sprite.texture.context.drawImage(
|
||||
sprite.texture.texture, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._sw, // Source Width
|
||||
this._sh, // Source Height
|
||||
this._dx, // Destination X (where on the canvas it'll be drawn)
|
||||
this._dy, // Destination Y
|
||||
this._dw, // Destination Width (always same as Source Width unless scaled)
|
||||
this._dh // Destination Height (always same as Source Height unless scaled)
|
||||
);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// this.context.fillStyle = this.fillColor;
|
||||
// this.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
//}
|
||||
|
||||
if (sprite.position.rotation !== 0 || sprite.position.rotationOffset !== 0 || sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
{
|
||||
//this.context.translate(0, 0);
|
||||
sprite.texture.context.restore();
|
||||
}
|
||||
|
||||
//if (this.renderDebug)
|
||||
//{
|
||||
// this.renderBounds(camera, cameraOffsetX, cameraOffsetY);
|
||||
//this.collisionMask.render(camera, cameraOffsetX, cameraOffsetY);
|
||||
//}
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
sprite.texture.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../cameras/Camera.ts" />
|
||||
/// <reference path="IRenderer.ts" />
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class HeadlessRenderer implements Phaser.IRenderer {
|
||||
|
||||
constructor(game: Game) {
|
||||
this._game = game;
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
public render() {}
|
||||
|
||||
public renderSprite(camera: Camera, sprite: Sprite): bool {
|
||||
|
||||
// Render checks (needs inCamera check added)
|
||||
if (sprite.scale.x == 0 || sprite.scale.y == 0 || sprite.texture.alpha < 0.1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Add Tilemap, ScrollZone, etc?
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
module Phaser {
|
||||
|
||||
export interface IRenderer {
|
||||
|
||||
// properties
|
||||
_game: Game;
|
||||
|
||||
// methods
|
||||
render();
|
||||
renderSprite(camera: Camera, sprite: Sprite): bool;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../SoundManager.ts" />
|
||||
/// <reference path="SoundManager.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Sound
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="system/Sound.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Sound.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - SoundManager
|
||||
|
||||
Vendored
-80
@@ -1,80 +0,0 @@
|
||||
/// <reference path="../gameobjects/Sprite.d.ts" />
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Camera {
|
||||
constructor(game: Game, id: number, x: number, y: number, width: number, height: number);
|
||||
private _game;
|
||||
private _clip;
|
||||
private _stageX;
|
||||
private _stageY;
|
||||
private _rotation;
|
||||
private _target;
|
||||
private _sx;
|
||||
private _sy;
|
||||
private _fxFlashColor;
|
||||
private _fxFlashComplete;
|
||||
private _fxFlashDuration;
|
||||
private _fxFlashAlpha;
|
||||
private _fxFadeColor;
|
||||
private _fxFadeComplete;
|
||||
private _fxFadeDuration;
|
||||
private _fxFadeAlpha;
|
||||
private _fxShakeIntensity;
|
||||
private _fxShakeDuration;
|
||||
private _fxShakeComplete;
|
||||
private _fxShakeOffset;
|
||||
private _fxShakeDirection;
|
||||
private _fxShakePrevX;
|
||||
private _fxShakePrevY;
|
||||
static STYLE_LOCKON: number;
|
||||
static STYLE_PLATFORMER: number;
|
||||
static STYLE_TOPDOWN: number;
|
||||
static STYLE_TOPDOWN_TIGHT: number;
|
||||
static SHAKE_BOTH_AXES: number;
|
||||
static SHAKE_HORIZONTAL_ONLY: number;
|
||||
static SHAKE_VERTICAL_ONLY: number;
|
||||
public ID: number;
|
||||
public worldView: Rectangle;
|
||||
public totalSpritesRendered: number;
|
||||
public scale: MicroPoint;
|
||||
public scroll: MicroPoint;
|
||||
public bounds: Rectangle;
|
||||
public deadzone: Rectangle;
|
||||
public showBorder: bool;
|
||||
public borderColor: string;
|
||||
public opaque: bool;
|
||||
private _bgColor;
|
||||
private _bgTexture;
|
||||
private _bgTextureRepeat;
|
||||
public showShadow: bool;
|
||||
public shadowColor: string;
|
||||
public shadowBlur: number;
|
||||
public shadowOffset: MicroPoint;
|
||||
public visible: bool;
|
||||
public alpha: number;
|
||||
public inputX: number;
|
||||
public inputY: number;
|
||||
public fx: FXManager;
|
||||
public flash(color?: number, duration?: number, onComplete?, force?: bool): void;
|
||||
public fade(color?: number, duration?: number, onComplete?, force?: bool): void;
|
||||
public shake(intensity?: number, duration?: number, onComplete?, force?: bool, direction?: number): void;
|
||||
public stopFX(): void;
|
||||
public follow(target: Sprite, style?: number): void;
|
||||
public focusOnXY(x: number, y: number): void;
|
||||
public focusOn(point): void;
|
||||
public setBounds(x?: number, y?: number, width?: number, height?: number): void;
|
||||
public update(): void;
|
||||
public render(): void;
|
||||
public backgroundColor : string;
|
||||
public setTexture(key: string, repeat?: string): void;
|
||||
public setPosition(x: number, y: number): void;
|
||||
public setSize(width: number, height: number): void;
|
||||
public renderDebugInfo(x: number, y: number, color?: string): void;
|
||||
public x : number;
|
||||
public y : number;
|
||||
public width : number;
|
||||
public height : number;
|
||||
public rotation : number;
|
||||
private checkClip();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user