Lots of Tilemap updates, moved the renderer out, added components and new tests.

This commit is contained in:
Richard Davey 2013-07-02 23:41:25 +01:00
parent c647792c12
commit c81cf0c882
34 changed files with 2395 additions and 1563 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -79,7 +79,7 @@ module Phaser.Components {
public cameraBlacklist: number[];
/**
* Whether the Sprite background is opaque or not. If set to true the Sprite is filled with
* Whether the texture background is opaque or not. If set to true the object is filled with
* the value of Texture.backgroundColor every frame. Normally you wouldn't enable this but
* for some effects it can be handy.
* @type {boolean}
@ -136,6 +136,12 @@ module Phaser.Components {
*/
public renderRotation: bool = true;
/**
* The direction the animation frame is facing (can be Phaser.Types.RIGHT, LEFT, UP, DOWN).
* Very useful when hooking animation to Sprite directions.
*/
public facing: number;
/**
* Flip the graphic horizontally (defaults to false)
* @type {boolean}

View file

@ -26,53 +26,36 @@ module Phaser {
*/
constructor(game: Game, parent:Tilemap, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number) {
this._game = game;
this._parent = parent;
this.game = game;
this.parent = parent;
this.name = name;
this.mapFormat = mapFormat;
this.tileWidth = tileWidth;
this.tileHeight = tileHeight;
this.boundsInTiles = new Rectangle();
//this.scrollFactor = new MicroPoint(1, 1);
this.canvas = game.stage.canvas;
this.context = game.stage.context;
this.texture = new Phaser.Components.Texture(this);
this.transform = new Phaser.Components.Transform(this);
if (key !== null)
{
this.texture.loadImage(key, false);
}
else
{
this.texture.opaque = true;
}
// Handy proxies
this.alpha = this.texture.alpha;
this.mapData = [];
this._tempTileBlock = [];
this._texture = this._game.cache.getImage(key);
}
/**
* Local private reference to game.
*/
private _game: Game;
/**
* The tilemap that contains this layer.
* @type {Tilemap}
*/
private _parent: Tilemap;
/**
* Tileset of this layer.
*/
private _texture;
private _tileOffsets;
private _startX: number = 0;
private _startY: number = 0;
private _maxX: number = 0;
private _maxY: number = 0;
private _tx: number = 0;
private _ty: number = 0;
private _dx: number = 0;
private _dy: number = 0;
private _oldCameraX: number = 0;
private _oldCameraY: number = 0;
private _columnData;
// Private vars to help avoid gc spikes
private _tempTileX: number;
private _tempTileY: number;
private _tempTileW: number;
@ -80,30 +63,40 @@ module Phaser {
private _tempTileBlock;
private _tempBlockResults;
/**
* Local private reference to game.
*/
public game: Game;
/**
* The tilemap that contains this layer.
* @type {Tilemap}
*/
public parent: Tilemap;
/**
* The texture used to render the Sprite.
*/
public texture: Phaser.Components.Texture;
/**
* The Sprite transform component.
*/
public transform: Phaser.Components.Transform;
public tileOffsets;
/**
* The alpha of the Sprite between 0 and 1, a value of 1 being fully opaque.
*/
public alpha: number;
/**
* Name of this layer, so you can get this layer by its name.
* @type {string}
*/
public name: string;
/**
* A reference to the Canvas this GameObject will render to
* @type {HTMLCanvasElement}
*/
public canvas: HTMLCanvasElement;
/**
* A reference to the Canvas Context2D this GameObject will render to
* @type {CanvasRenderingContext2D}
*/
public context: CanvasRenderingContext2D;
/**
* Opacity of this layer.
* @type {number}
*/
public alpha: number = 1;
/**
* Controls whether update() and draw() are automatically called.
* @type {boolean}
@ -116,11 +109,10 @@ module Phaser {
*/
public visible: bool = true;
//public scrollFactor: MicroPoint;
/**
* @type {string}
*/
public orientation: string;
//public orientation: string;
/**
* Properties of this map layer. (normally set by map editors)
@ -202,8 +194,8 @@ module Phaser {
*/
public putTile(x: number, y: number, index: number) {
x = this._game.math.snapToFloor(x, this.tileWidth) / this.tileWidth;
y = this._game.math.snapToFloor(y, this.tileHeight) / this.tileHeight;
x = this.game.math.snapToFloor(x, this.tileWidth) / this.tileWidth;
y = this.game.math.snapToFloor(y, this.tileHeight) / this.tileHeight;
if (y >= 0 && y < this.mapData.length)
{
@ -287,7 +279,7 @@ module Phaser {
for (var r = 0; r < this._tempTileBlock.length; r++)
{
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = this._game.math.getRandom(tiles);
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = this.game.math.getRandom(tiles);
}
}
@ -344,8 +336,8 @@ module Phaser {
*/
public getTileFromWorldXY(x: number, y: number): number {
x = this._game.math.snapToFloor(x, this.tileWidth) / this.tileWidth;
y = this._game.math.snapToFloor(y, this.tileHeight) / this.tileHeight;
x = this.game.math.snapToFloor(x, this.tileWidth) / this.tileWidth;
y = this.game.math.snapToFloor(y, this.tileHeight) / this.tileHeight;
return this.getTileIndex(x, y);
@ -365,10 +357,10 @@ module Phaser {
}
// What tiles do we need to check against?
this._tempTileX = this._game.math.snapToFloor(object.body.bounds.x, this.tileWidth) / this.tileWidth;
this._tempTileY = this._game.math.snapToFloor(object.body.bounds.y, this.tileHeight) / this.tileHeight;
this._tempTileW = (this._game.math.snapToCeil(object.body.bounds.width, this.tileWidth) + this.tileWidth) / this.tileWidth;
this._tempTileH = (this._game.math.snapToCeil(object.body.bounds.height, this.tileHeight) + this.tileHeight) / this.tileHeight;
this._tempTileX = this.game.math.snapToFloor(object.body.bounds.x, this.tileWidth) / this.tileWidth;
this._tempTileY = this.game.math.snapToFloor(object.body.bounds.y, this.tileHeight) / this.tileHeight;
this._tempTileW = (this.game.math.snapToCeil(object.body.bounds.width, this.tileWidth) + this.tileWidth) / this.tileWidth;
this._tempTileH = (this.game.math.snapToCeil(object.body.bounds.height, this.tileHeight) + this.tileHeight) / this.tileHeight;
// Loop through the tiles we've got and check overlaps accordingly (the results are stored in this._tempTileBlock)
@ -378,7 +370,7 @@ module Phaser {
/*
for (var r = 0; r < this._tempTileBlock.length; r++)
{
if (this._game.world.physics.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY) == true)
if (this.game.world.physics.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY) == true)
{
this._tempBlockResults.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile });
}
@ -428,16 +420,16 @@ module Phaser {
if (collisionOnly)
{
// We only want to consider the tile for checking if you can actually collide with it
if (this.mapData[ty] && this.mapData[ty][tx] && this._parent.tiles[this.mapData[ty][tx]].allowCollisions != Types.NONE)
if (this.mapData[ty] && this.mapData[ty][tx] && this.parent.tiles[this.mapData[ty][tx]].allowCollisions != Types.NONE)
{
this._tempTileBlock.push({ x: tx, y: ty, tile: this._parent.tiles[this.mapData[ty][tx]] });
this._tempTileBlock.push({ x: tx, y: ty, tile: this.parent.tiles[this.mapData[ty][tx]] });
}
}
else
{
if (this.mapData[ty] && this.mapData[ty][tx])
{
this._tempTileBlock.push({ x: tx, y: ty, tile: this._parent.tiles[this.mapData[ty][tx]] });
this._tempTileBlock.push({ x: tx, y: ty, tile: this.parent.tiles[this.mapData[ty][tx]] });
}
}
}
@ -502,34 +494,35 @@ module Phaser {
/**
* Parse tile offsets from map data.
* @return {number} length of _tileOffsets array.
* @return {number} length of tileOffsets array.
*/
public parseTileOffsets():number {
this._tileOffsets = [];
this.tileOffsets = [];
var i = 0;
if (this.mapFormat == Tilemap.FORMAT_TILED_JSON)
{
// For some reason Tiled counts from 1 not 0
this._tileOffsets[0] = null;
this.tileOffsets[0] = null;
i = 1;
}
for (var ty = this.tileMargin; ty < this._texture.height; ty += (this.tileHeight + this.tileSpacing))
for (var ty = this.tileMargin; ty < this.texture.height; ty += (this.tileHeight + this.tileSpacing))
{
for (var tx = this.tileMargin; tx < this._texture.width; tx += (this.tileWidth + this.tileSpacing))
for (var tx = this.tileMargin; tx < this.texture.width; tx += (this.tileWidth + this.tileSpacing))
{
this._tileOffsets[i] = { x: tx, y: ty };
this.tileOffsets[i] = { x: tx, y: ty };
i++;
}
}
return this._tileOffsets.length;
return this.tileOffsets.length;
}
/*
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
this.context.fillStyle = color;
@ -539,125 +532,7 @@ module Phaser {
this.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42);
}
/**
* Render this layer to a specific camera with offset to camera.
* @param camera {Camera} The camera the layer is going to be rendered.
* @param dx {number} X offset to the camera.
* @param dy {number} Y offset to the camera.
* @return {boolean} Return false if layer is invisible or has a too low opacity(will stop rendering), return true if succeed.
*/
public render(camera: Camera, dx, dy): bool {
if (this.visible === false || this.alpha < 0.1)
{
return false;
}
// Work out how many tiles we can fit into our camera and round it up for the edges
this._maxX = this._game.math.ceil(camera.width / this.tileWidth) + 1;
this._maxY = this._game.math.ceil(camera.height / this.tileHeight) + 1;
// And now work out where in the tilemap the camera actually is
this._startX = this._game.math.floor(camera.worldView.x / this.tileWidth);
this._startY = this._game.math.floor(camera.worldView.y / this.tileHeight);
// Tilemap bounds check
if (this._startX < 0)
{
this._startX = 0;
}
if (this._startY < 0)
{
this._startY = 0;
}
if (this._maxX > this.widthInTiles)
{
this._maxX = this.widthInTiles;
}
if (this._maxY > this.heightInTiles)
{
this._maxY = this.heightInTiles;
}
if (this._startX + this._maxX > this.widthInTiles)
{
this._startX = this.widthInTiles - this._maxX;
}
if (this._startY + this._maxY > this.heightInTiles)
{
this._startY = this.heightInTiles - this._maxY;
}
// Finally get the offset to avoid the blocky movement
this._dx = dx;
this._dy = dy;
this._dx += -(camera.worldView.x - (this._startX * this.tileWidth));
this._dy += -(camera.worldView.y - (this._startY * this.tileHeight));
this._tx = this._dx;
this._ty = this._dy;
// Apply camera difference
/*
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
{
this._dx -= (camera.worldView.x * this.scrollFactor.x);
this._dy -= (camera.worldView.y * this.scrollFactor.y);
}
*/
// Alpha
if (this.alpha !== 1)
{
var globalAlpha = this.context.globalAlpha;
this.context.globalAlpha = this.alpha;
}
for (var row = this._startY; row < this._startY + this._maxY; row++)
{
this._columnData = this.mapData[row];
for (var tile = this._startX; tile < this._startX + this._maxX; tile++)
{
if (this._tileOffsets[this._columnData[tile]])
{
this.context.drawImage(
this._texture, // Source Image
this._tileOffsets[this._columnData[tile]].x, // Source X (location within the source image)
this._tileOffsets[this._columnData[tile]].y, // Source Y
this.tileWidth, // Source Width
this.tileHeight, // Source Height
this._tx, // Destination X (where on the canvas it'll be drawn)
this._ty, // Destination Y
this.tileWidth, // Destination Width (always same as Source Width unless scaled)
this.tileHeight // Destination Height (always same as Source Height unless scaled)
);
}
this._tx += this.tileWidth;
}
this._tx = this._dx;
this._ty += this.tileHeight;
}
if (globalAlpha > -1)
{
this.context.globalAlpha = globalAlpha;
}
return true;
}
*/
}
}

View file

@ -24,10 +24,13 @@ module Phaser.Components.Sprite {
this.onKilled = new Phaser.Signal;
this.onRevived = new Phaser.Signal;
// Only create these if Sprite input is enabled?
this.onInputOver = new Phaser.Signal;
this.onInputOut = new Phaser.Signal;
this.onInputDown = new Phaser.Signal;
this.onInputUp = new Phaser.Signal;
this.onDragStart = new Phaser.Signal;
this.onDragStop = new Phaser.Signal;
}
@ -81,6 +84,15 @@ module Phaser.Components.Sprite {
*/
public onInputUp: Phaser.Signal;
/**
* Dispatched by the Input component when the Sprite starts being dragged
*/
public onDragStart: Phaser.Signal;
/**
* Dispatched by the Input component when the Sprite stops being dragged
*/
public onDragStop: Phaser.Signal;

View file

@ -595,6 +595,8 @@ module Phaser.Components.Sprite {
this.sprite.group.bringToTop(this.sprite);
}
this.sprite.events.onDragStart.dispatch(this.sprite, pointer);
}
/**
@ -612,7 +614,7 @@ module Phaser.Components.Sprite {
this.sprite.y = Math.floor(this.sprite.y / this.snapY) * this.snapY;
}
//pointer.draggedObject = null;
this.sprite.events.onDragStop.dispatch(this.sprite, pointer);
}
/**

View file

@ -618,17 +618,58 @@ module Phaser {
public bringToTop(child): bool {
//console.log('bringToTop', child.name,'current z', child.z);
var oldZ = child.z;
// If child not in this group, or is already at the top of the group, return false
if (!child || child.group == null || child.group.ID != this.ID || child.z == this._zCounter)
//if (!child || child.group == null || child.group.ID != this.ID || child.z == this._zCounter)
if (!child || child.group == null || child.group.ID != this.ID)
{
//console.log('If child not in this group, or is already at the top of the group, return false');
return false;
}
// Find out the largest z index
var topZ: number = -1;
for (var i = 0; i < this.length; i++)
{
if (this.members[i] && this.members[i].z > topZ)
{
topZ = this.members[i].z;
}
}
// Child is already at the top
if (child.z == topZ)
{
return false;
}
child.z = topZ + 1;
// Sort them out based on the current z indexes
this.sort();
// Now tidy-up the z indexes, removing gaps, etc
for (var i = 0; i < this.length; i++)
{
if (this.members[i])
{
this.members[i].z = i;
}
}
//console.log('bringToTop', child.name, 'old z', oldZ, 'new z', child.z);
return true;
// What's the z index of the top most child?
/*
var childIndex: number = this._zCounter;
console.log('childIndex', childIndex);
this._i = 0;
while (this._i < this.length)
@ -649,10 +690,13 @@ module Phaser {
}
}
console.log('child inserted at index', child.z);
// Maybe redundant?
this.sort();
return true;
*/
}

View file

@ -19,6 +19,11 @@ module Phaser {
*/
group: Group;
/**
* The name of the Game Object. Typically not set by Phaser, but extremely useful for debugging / logic.
*/
name: string;
/**
* x value of the object.
*/

View file

@ -23,7 +23,7 @@ module Phaser {
* @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 [bodyType] {number} The physics body type of the object (defaults to BODY_DISABLED)
* @param [bodyType] {number} The physics body type of the object (defaults to BODY_DISABLED, i.e. no physics)
* @param [shapeType] {number} The physics shape the body will consist of (either Box (0) or Circle (1), for custom types see body.addShape)
*/
constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null, frame? = null, bodyType?: number = Phaser.Types.BODY_DISABLED, shapeType?:number = 0) {
@ -40,6 +40,7 @@ module Phaser {
this.y = y;
this.z = -1;
this.group = null;
this.name = '';
this.animations = new Phaser.Components.AnimationManager(this);
this.input = new Phaser.Components.Sprite.Input(this);
@ -97,6 +98,11 @@ module Phaser {
*/
public type: number;
/**
* The name of game object.
*/
public name: string;
/**
* The Group this Sprite belongs to.
*/
@ -183,7 +189,7 @@ module Phaser {
/**
* z order value of the object.
*/
public z: number = 0;
public z: number = -1;
/**
* Render iteration counter
@ -202,7 +208,14 @@ module Phaser {
* The value is automatically wrapped to be between 0 and 360.
*/
public set rotation(value: number) {
this.transform.rotation = this.game.math.wrap(value, 360, 0);
if (this.body)
{
this.body.angle = this.game.math.degreesToRadians(this.game.math.wrap(value, 360, 0));
}
}
/**

View file

@ -35,9 +35,15 @@ module Phaser {
this.visible = true;
this.alive = true;
this.z = -1;
this.group = null;
this.name = '';
this.texture = new Phaser.Components.Texture(this);
this.transform = new Phaser.Components.Transform(this);
this.tiles = [];
this.layers = [];
this.cameraBlacklist = [];
this.mapFormat = format;
@ -71,6 +77,16 @@ module Phaser {
*/
public type: number;
/**
* The name of game object.
*/
public name: string;
/**
* The Group this Sprite belongs to.
*/
public group: Group;
/**
* Controls if both <code>update</code> and render are called by the core game loop.
*/
@ -87,10 +103,44 @@ module Phaser {
public visible: bool;
/**
*
* A useful state for many game objects. Kill and revive both flip this switch.
*/
public alive: bool;
/**
* The texture used to render the Sprite.
*/
public texture: Phaser.Components.Texture;
/**
* The Sprite transform component.
*/
public transform: Phaser.Components.Transform;
/**
* The Input component
*/
//public input: Phaser.Components.Sprite.Input;
/**
* The Events component
*/
//public events: Phaser.Components.Sprite.Events;
/**
* z order value of the object.
*/
public z: number = -1;
/**
* Render iteration counter
*/
public renderOrderID: number = 0;
/**
* Tilemap data format enum: CSV.
* @type {number}
@ -145,34 +195,15 @@ module Phaser {
public mapFormat: number;
/**
* An Array of Cameras to which this GameObject won't render
* @type {Array}
* Inherited methods for overriding.
*/
public cameraBlacklist: number[];
/**
* Inherited update method.
*/
public update() {
public preUpdate() {
}
/**
* Render this tilemap to a specific camera with specific offset.
* @param camera {Camera} The camera this tilemap will be rendered to.
* @param cameraOffsetX {number} X offset of the camera.
* @param cameraOffsetY {number} Y offset of the camera.
*/
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
if (this.cameraBlacklist.indexOf(camera.ID) == -1)
{
// Loop through the layers
for (var i = 0; i < this.layers.length; i++)
{
this.layers[i].render(camera, cameraOffsetX, cameraOffsetY);
}
}
public update() {
}
public postUpdate() {
}
/**
@ -202,6 +233,7 @@ module Phaser {
}
layer.updateBounds();
var tileQuantity = layer.parseTileOffsets();
this.currentLayer = layer;

View file

@ -1,3 +1,19 @@
/**
* Phaser
*
* 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, 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."
* -- Albert Einstein
*/
var Phaser;
(function (Phaser) {
Phaser.VERSION = 'Phaser version 1.0.0';

View file

@ -35,7 +35,7 @@ module Phaser.Physics {
this.sprite = sprite;
this.game = sprite.game;
this.position = new Phaser.Vec2(Phaser.Physics.Manager.pixelsToMeters(sprite.x), Phaser.Physics.Manager.pixelsToMeters(sprite.y));
this.angle = sprite.rotation;
this.angle = this.game.math.degreesToRadians(sprite.rotation);
}
else
{
@ -61,7 +61,6 @@ module Phaser.Physics {
this.bounds = new Bounds;
this.allowCollisions = Phaser.Types.ANY;
this.fixedRotation = false;
this.categoryBits = 0x0001;
this.maskBits = 0xFFFF;
@ -82,11 +81,8 @@ module Phaser.Physics {
}
public toString(): string {
return "[{Body (name=" + this.name + " velocity=" + this.velocity.toString() + " angularVelocity: " + this.angularVelocity + ")}]";
}
private _tempVec2: Phaser.Vec2 = new Phaser.Vec2;
private _fixedRotation: bool = false;
/**
* Reference to Phaser.Game
@ -118,8 +114,26 @@ module Phaser.Physics {
*/
public type: number;
/**
* The angle of the body in radians. Used by all of the internal physics methods.
*/
public angle: number;
/**
* The rotation of the body in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
*/
public get rotation(): number {
return this.game.math.radiansToDegrees(this.angle);
}
/**
* Set the rotation of the body in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
* The value is automatically wrapped to be between 0 and 360.
*/
public set rotation(value: number) {
this.angle = this.game.math.degreesToRadians(this.game.math.wrap(value, 360, 0));
}
// Local to world transform
public transform: Phaser.Transform;
@ -174,17 +188,16 @@ module Phaser.Physics {
public inertia: number;
public inertiaInverted: number;
public fixedRotation = false;
public categoryBits = 0x0001;
public maskBits = 0xFFFF;
public stepCount = 0;
public categoryBits: number = 0x0001;
public maskBits: number = 0xFFFF;
public stepCount: number = 0;
public space: Space;
public duplicate() {
console.log('body duplicate called');
//var body = new Body(this.type, this.transform.t, this.angle);
//var body = new Body(this.type, this.transform.t, this.rotation);
//for (var i = 0; i < this.shapes.length; i++)
//{
@ -313,28 +326,28 @@ module Phaser.Physics {
}
private setMass(mass) {
private setMass(mass:number) {
this.mass = mass;
this.massInverted = mass > 0 ? 1 / mass : 0;
}
private setInertia(inertia) {
private setInertia(inertia:number) {
this.inertia = inertia;
this.inertiaInverted = inertia > 0 ? 1 / inertia : 0;
}
public setTransform(pos, angle) {
public setTransform(pos:Phaser.Vec2, angle:number) {
// inject the transform into this.position
this.transform.setTo(pos, angle);
Manager.write('setTransform: ' + this.position.toString());
Manager.write('centroid: ' + this.centroid.toString());
//Manager.write('setTransform: ' + this.position.toString());
//Manager.write('centroid: ' + this.centroid.toString());
Phaser.TransformUtils.transform(this.transform, this.centroid, this.position);
Manager.write('post setTransform: ' + this.position.toString());
//Manager.write('post setTransform: ' + this.position.toString());
//this.position.copyFrom(this.transform.transform(this.centroid));
this.angle = angle;
@ -342,17 +355,17 @@ module Phaser.Physics {
public syncTransform() {
Manager.write('syncTransform:');
Manager.write('p: ' + this.position.toString());
Manager.write('centroid: ' + this.centroid.toString());
Manager.write('xf: ' + this.transform.toString());
Manager.write('a: ' + this.angle);
//Manager.write('syncTransform:');
//Manager.write('p: ' + this.position.toString());
//Manager.write('centroid: ' + this.centroid.toString());
//Manager.write('xf: ' + this.transform.toString());
//Manager.write('a: ' + this.angle);
this.transform.setRotation(this.angle);
// OPTIMISE: Creating new vector
Phaser.Vec2Utils.subtract(this.position, Phaser.TransformUtils.rotate(this.transform, this.centroid), this.transform.t);
Manager.write('--------------------');
Manager.write('xf: ' + this.transform.toString());
Manager.write('--------------------');
//Manager.write('--------------------');
//Manager.write('xf: ' + this.transform.toString());
//Manager.write('--------------------');
}
@ -376,9 +389,16 @@ module Phaser.Physics {
return Phaser.TransformUtils.unrotate(this.transform, v);
}
public setFixedRotation(flag) {
this.fixedRotation = flag;
public set fixedRotation(value:bool) {
this._fixedRotation = value;
this.resetMassData();
}
public get fixedRotation(): bool {
return this._fixedRotation;
}
public resetMassData() {
@ -392,7 +412,6 @@ module Phaser.Physics {
if (this.isDynamic == false)
{
Phaser.TransformUtils.transform(this.transform, this.centroid, this.position);
//this.position.copyFrom(this.transform.transform(this.centroid));
return;
}
@ -407,14 +426,11 @@ module Phaser.Physics {
var mass = shape.area() * shape.density;
var inertia = shape.inertia(mass);
//console.log('rmd', centroid, shape);
totalMassCentroid.multiplyAddByScalar(centroid, mass);
totalMass += mass;
totalInertia += inertia;
}
//this.centroid.copy(vec2.scale(totalMassCentroid, 1 / totalMass));
Phaser.Vec2Utils.scale(totalMassCentroid, 1 / totalMass, this.centroid);
this.setMass(totalMass);
@ -455,9 +471,9 @@ module Phaser.Physics {
public cacheData(source:string = '') {
Manager.write('cacheData -- start');
Manager.write('p: ' + this.position.toString());
Manager.write('xf: ' + this.transform.toString());
//Manager.write('cacheData -- start');
//Manager.write('p: ' + this.position.toString());
//Manager.write('xf: ' + this.transform.toString());
this.bounds.clear();
@ -468,11 +484,11 @@ module Phaser.Physics {
this.bounds.addBounds(shape.bounds);
}
Manager.write('bounds: ' + this.bounds.toString());
//Manager.write('bounds: ' + this.bounds.toString());
Manager.write('p: ' + this.position.toString());
Manager.write('xf: ' + this.transform.toString());
Manager.write('cacheData -- stop');
//Manager.write('p: ' + this.position.toString());
//Manager.write('xf: ' + this.transform.toString());
//Manager.write('cacheData -- stop');
}
@ -538,15 +554,16 @@ module Phaser.Physics {
{
this.sprite.x = this.position.x * 50;
this.sprite.y = this.position.y * 50;
// Obey fixed rotation?
this.sprite.rotation = this.game.math.radiansToDegrees(this.angle);
this.sprite.transform.rotation = this.game.math.radiansToDegrees(this.angle);
}
}
public resetForce() {
this.force.setTo(0, 0);
this.torque = 0;
}
public applyForce(force:Phaser.Vec2, p:Phaser.Vec2) {
@ -638,11 +655,8 @@ module Phaser.Physics {
}
public kineticEnergy() {
var vsq = this.velocity.dot(this.velocity);
var wsq = this.angularVelocity * this.angularVelocity;
return 0.5 * (this.mass * vsq + this.inertia * wsq);
return 0.5 * (this.mass * this.velocity.dot(this.velocity) + this.inertia * (this.angularVelocity * this.angularVelocity));
}
@ -670,12 +684,7 @@ module Phaser.Physics {
public isCollidable(other:Body) {
if (this == other)
{
return false;
}
if (this.isDynamic == false && other.isDynamic == false)
if ((this.isDynamic == false && other.isDynamic == false) || this == other)
{
return false;
}
@ -699,6 +708,10 @@ module Phaser.Physics {
}
public toString(): string {
return "[{Body (name=" + this.name + " velocity=" + this.velocity.toString() + " angularVelocity: " + this.angularVelocity + ")}]";
}
}
}

View file

@ -313,12 +313,8 @@ module Phaser.Physics {
var r2 = new Phaser.Vec2;
// Transformed r1, r2
Phaser.Vec2Utils.rotate(con.r1_local, body1.angle, r1);
//var r1 = vec2.rotate(con.r1_local, body1.a);
Phaser.Vec2Utils.rotate(con.r2_local, body2.angle, r2);
//var r2 = vec2.rotate(con.r2_local, body2.a);
Manager.write('r1_local.x = ' + con.r1_local.x + ' r1_local.y = ' + con.r1_local.y + ' angle: ' + body1.angle);
Manager.write('r1 rotated: r1.x = ' + r1.x + ' r1.y = ' + r1.y);
@ -330,10 +326,7 @@ module Phaser.Physics {
var p2 = new Phaser.Vec2;
Phaser.Vec2Utils.add(body1.position, r1, p1);
//var p1 = vec2.add(body1.p, r1);
Phaser.Vec2Utils.add(body2.position, r2, p2);
//var p2 = vec2.add(body2.p, r2);
Manager.write('body1.pos.x=' + body1.position.x + ' y=' + body1.position.y);
Manager.write('body2.pos.x=' + body2.position.x + ' y=' + body2.position.y);
@ -341,7 +334,6 @@ module Phaser.Physics {
// Corrected delta vector
var dp = new Phaser.Vec2;
Phaser.Vec2Utils.subtract(p2, p1, dp);
//var dp = vec2.sub(p2, p1);
// Position constraint
var c = Phaser.Vec2Utils.dot(dp, n) + con.depth;
@ -368,16 +360,11 @@ module Phaser.Physics {
// Apply correction impulses
var impulse_dt = new Phaser.Vec2;
Phaser.Vec2Utils.scale(n, lambda_dt, impulse_dt);
//var impulse_dt = vec2.scale(n, lambda_dt);
body1.position.multiplyAddByScalar(impulse_dt, -m1_inv);
//body1.p.mad(impulse_dt, -m1_inv);
body1.angle -= sn1 * lambda_dt * i1_inv;
body2.position.multiplyAddByScalar(impulse_dt, m2_inv);
//body2.p.mad(impulse_dt, m2_inv);
body2.angle += sn2 * lambda_dt * i2_inv;
Manager.write('body1.pos.x=' + body1.position.x + ' y=' + body1.position.y);

View file

@ -17,7 +17,7 @@ module Phaser {
*/
private _game: Phaser.Game;
// local rendering related temp vars to help avoid gc spikes with var creation
// Local rendering related temp vars to help avoid gc spikes through var creation
private _ga: number = 1;
private _sx: number = 0;
private _sy: number = 0;
@ -29,9 +29,15 @@ module Phaser {
private _dh: number = 0;
private _fx: number = 1;
private _fy: number = 1;
private _tx: number = 0;
private _ty: number = 0;
private _sin: number = 0;
private _cos: number = 1;
private _maxX: number = 0;
private _maxY: number = 0;
private _startX: number = 0;
private _startY: number = 0;
private _columnData;
private _cameraList;
private _camera: Camera;
private _groupLength: number;
@ -74,6 +80,10 @@ module Phaser {
{
this.renderScrollZone(this._camera, object);
}
else if (object.type == Types.TILEMAP)
{
this.renderTilemap(this._camera, object);
}
}
@ -668,6 +678,124 @@ module Phaser {
}
/**
* Render a tilemap to a specific camera.
* @param camera {Camera} The camera this tilemap will be rendered to.
*/
public renderTilemap(camera: Camera, tilemap: Tilemap): bool {
// Loop through the layers
for (var i = 0; i < tilemap.layers.length; i++)
{
var layer: TilemapLayer = tilemap.layers[i];
if (layer.visible == false || layer.alpha < 0.1)
{
continue;
}
// Work out how many tiles we can fit into our camera and round it up for the edges
this._maxX = this._game.math.ceil(camera.width / layer.tileWidth) + 1;
this._maxY = this._game.math.ceil(camera.height / layer.tileHeight) + 1;
// And now work out where in the tilemap the camera actually is
this._startX = this._game.math.floor(camera.worldView.x / layer.tileWidth);
this._startY = this._game.math.floor(camera.worldView.y / layer.tileHeight);
// Tilemap bounds check
if (this._startX < 0)
{
this._startX = 0;
}
if (this._startY < 0)
{
this._startY = 0;
}
if (this._maxX > layer.widthInTiles)
{
this._maxX = layer.widthInTiles;
}
if (this._maxY > layer.heightInTiles)
{
this._maxY = layer.heightInTiles;
}
if (this._startX + this._maxX > layer.widthInTiles)
{
this._startX = layer.widthInTiles - this._maxX;
}
if (this._startY + this._maxY > layer.heightInTiles)
{
this._startY = layer.heightInTiles - this._maxY;
}
// Finally get the offset to avoid the blocky movement
//this._dx = (camera.screenView.x * layer.transform.scrollFactor.x) - (camera.worldView.x * layer.transform.scrollFactor.x);
//this._dy = (camera.screenView.y * layer.transform.scrollFactor.y) - (camera.worldView.y * layer.transform.scrollFactor.y);
//this._dx = (camera.screenView.x * this.scrollFactor.x) + this.x - (camera.worldView.x * this.scrollFactor.x);
//this._dy = (camera.screenView.y * this.scrollFactor.y) + this.y - (camera.worldView.y * this.scrollFactor.y);
this._dx = 0;
this._dy = 0;
this._dx += -(camera.worldView.x - (this._startX * layer.tileWidth));
this._dy += -(camera.worldView.y - (this._startY * layer.tileHeight));
this._tx = this._dx;
this._ty = this._dy;
// Alpha
if (layer.texture.alpha !== 1)
{
this._ga = layer.texture.context.globalAlpha;
layer.texture.context.globalAlpha = layer.texture.alpha;
}
for (var row = this._startY; row < this._startY + this._maxY; row++)
{
this._columnData = layer.mapData[row];
for (var tile = this._startX; tile < this._startX + this._maxX; tile++)
{
if (layer.tileOffsets[this._columnData[tile]])
{
layer.texture.context.drawImage(
layer.texture.texture,
layer.tileOffsets[this._columnData[tile]].x,
layer.tileOffsets[this._columnData[tile]].y,
layer.tileWidth,
layer.tileHeight,
this._tx,
this._ty,
layer.tileWidth,
layer.tileHeight
);
}
this._tx += layer.tileWidth;
}
this._tx = this._dx;
this._ty += layer.tileHeight;
}
if (this._ga > -1)
{
layer.texture.context.globalAlpha = this._ga;
}
}
return true;
}
}
}

View file

@ -187,6 +187,8 @@ module Phaser {
}
public isRunning: bool = false;
/**
* Start to tween.
*/
@ -205,6 +207,7 @@ module Phaser {
}
this._startTime = this._game.time.now + this._delayTime;
this.isRunning = true;
for (var property in this._valuesEnd)
{
@ -289,6 +292,8 @@ module Phaser {
this._manager.remove(this);
}
this.isRunning = false;
this.onComplete.dispose();
return this;
@ -432,6 +437,11 @@ module Phaser {
this._chainedTweens[i].start();
}
if (this._chainedTweens.length == 0)
{
this.isRunning = false;
}
return false;
}

View file

@ -91,6 +91,13 @@ module Phaser {
}
static renderRectangle(rect: Phaser.Rectangle, fillStyle: string = 'rgba(0,255,0,0.3)') {
DebugUtils.context.fillStyle = fillStyle;
DebugUtils.context.fillRect(rect.x, rect.y, rect.width, rect.height);
}
static renderPhysicsBody(body: Phaser.Physics.Body, lineWidth: number = 1, fillStyle: string = 'rgba(0,255,0,0.2)', sleepStyle: string = 'rgba(100,100,100,0.2)') {
for (var s = 0; s < body.shapesLength; s++)

View file

@ -11,7 +11,7 @@
module Phaser {
class PointUtils {
export class PointUtils {
/**
* Adds the coordinates of two points together to create a new point.

View file

@ -53,7 +53,13 @@ TODO:
* See about optimising Advanced Physics a lot more, so it doesn't create lots of Vec2s everywhere.
* QuadTree.physics.checkHullIntersection
* Fix the Motion methods for the new physics system
* Moved findShapeByPoint etc from Space to Manager (or at least add a proxy to them)
* Move findShapeByPoint etc from Space to Manager (or at least add a proxy to them)
* Make onInput events created only if input component is started
* Add button mode linked to sprite frames
* Add visible toggle if tween property is alpha <> 01
* Camera.isHidden uses an array and length check, faster to swap for a single counter, also try to remove indexOf check
* Tilemap.render - move layers length to var
* Camera control method (touch/keyboard)
V1.0.0
@ -126,7 +132,10 @@ V1.0.0
* Fixed issue in Tilemap.parseTiledJSON where it would accidentally think image and object layers were map data.
* Fixed bug in Group.bringToTop if the child didn't have a group property yet.
* Fixed bug in FrameData.checkFrameName where the first index of the _frameNames array would be skipped.
* Added isRunning boolean property to Phaser.Tween
* Moved 'facing' property from Sprite.body to Sprite.texture (may move to Sprite core)
* Added Sprite.events.onDragStart and onDragStop
* A tilemap can now be loaded without a tile sheet, should you just want to get the tile data from it and not render.
V0.9.6

View file

@ -217,6 +217,22 @@
<Content Include="sprites\origin 5.js">
<DependentUpon>origin 5.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="tilemaps\csv tilemap.ts" />
<Content Include="tilemaps\csv tilemap.js">
<DependentUpon>csv tilemap.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="tilemaps\tiled tilemap.ts" />
<TypeScriptCompile Include="tilemaps\tiled layers.ts" />
<TypeScriptCompile Include="tilemaps\map draw.ts" />
<Content Include="tilemaps\map draw.js">
<DependentUpon>map draw.ts</DependentUpon>
</Content>
<Content Include="tilemaps\tiled layers.js">
<DependentUpon>tiled layers.ts</DependentUpon>
</Content>
<Content Include="tilemaps\tiled tilemap.js">
<DependentUpon>tiled tilemap.ts</DependentUpon>
</Content>
<Content Include="tweens\tween loop 1.js">
<DependentUpon>tween loop 1.ts</DependentUpon>
</Content>

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,8 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.start();
@ -8,10 +10,21 @@
var atari;
var ball;
function create() {
// Add some gravity to the world, otherwise nothing will actually happen
game.physics.gravity.setTo(0, 5);
// We'll make the atari sprite a static body, so it won't be influenced by gravity or other forces
atari = game.add.physicsSprite(300, 450, 'atari', null, Phaser.Types.BODY_STATIC);
//atari.rotation = 10;
//atari.body.transform.setRotation(1);
atari.body.angle = 1;
// atari = 220px width (110 = center x)
// ball = 32px width (16 = center x)
// Ball will be a dynamic body and fall based on gravity
ball = game.add.physicsSprite(300 - 20, 0, 'ball');
}
ball.body.angle = 1;
//ball.body.transform.setRotation(1);
//ball.body.fixedRotation = true;
}
function render() {
Phaser.DebugUtils.renderPhysicsBodyInfo(atari.body, 32, 32);
Phaser.DebugUtils.renderPhysicsBodyInfo(ball.body, 320, 32);

View file

@ -23,12 +23,18 @@
// We'll make the atari sprite a static body, so it won't be influenced by gravity or other forces
atari = game.add.physicsSprite(300, 450, 'atari', null, Phaser.Types.BODY_STATIC);
//atari.rotation = 10;
//atari.body.transform.setRotation(1);
atari.body.angle = 1;
// atari = 220px width (110 = center x)
// ball = 32px width (16 = center x)
// Ball will be a dynamic body and fall based on gravity
ball = game.add.physicsSprite(300-20, 0, 'ball');
ball.body.angle = 1;
//ball.body.transform.setRotation(1);
//ball.body.fixedRotation = true;
}

View file

@ -0,0 +1,32 @@
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// CSV Tilemap Test
// First we load our map data (a csv file)
game.load.text('csvtest', 'assets/maps/catastrophi_level2.csv');
// Then we load the actual tile sheet image
game.load.image('csvtiles', 'assets/tiles/catastrophi_tiles_16.png');
game.load.start();
}
function create() {
// This creates the tilemap using the csv and tile sheet we loaded.
// We tell it use to CSV format parser. The 16x16 are the tile sizes.
// The 4th parameter (true) tells the game world to resize itself based on the map dimensions or not.
game.add.tilemap('csvtiles', 'csvtest', Phaser.Tilemap.FORMAT_CSV, true, 16, 16);
}
function update() {
// Simple camera controls
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
game.camera.x -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
game.camera.x += 4;
}
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
game.camera.y -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
game.camera.y += 4;
}
}
})();

View file

@ -0,0 +1,54 @@
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// CSV Tilemap Test
// First we load our map data (a csv file)
game.load.text('csvtest', 'assets/maps/catastrophi_level2.csv');
// Then we load the actual tile sheet image
game.load.image('csvtiles', 'assets/tiles/catastrophi_tiles_16.png');
game.load.start();
}
function create() {
// This creates the tilemap using the csv and tile sheet we loaded.
// We tell it use to CSV format parser. The 16x16 are the tile sizes.
// The 4th parameter (true) tells the game world to resize itself based on the map dimensions or not.
game.add.tilemap('csvtiles', 'csvtest', Phaser.Tilemap.FORMAT_CSV, true, 16, 16);
}
function update() {
// Simple camera controls
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += 4;
}
}
})();

View file

@ -0,0 +1,41 @@
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
game.load.text('platform', 'assets/maps/mapdraw.json');
game.load.image('tiles', 'assets/tiles/platformer_tiles.png');
game.load.image('carrot', 'assets/sprites/carrot.png');
game.load.start();
}
var map;
var emitter;
var marker;
function create() {
map = game.add.tilemap('tiles', 'platform', Phaser.Tilemap.FORMAT_TILED_JSON);
map.setCollisionRange(21, 53);
map.setCollisionRange(105, 109);
game.camera.texture.opaque = true;
game.camera.texture.backgroundColor = 'rgb(47,154,204)';
marker = game.add.sprite(0, 0);
marker.texture.width = 16;
marker.texture.height = 16;
marker.texture.opaque = true;
marker.texture.backgroundColor = 'rgba(255,0,0,0.4)';
//emitter = game.add.emitter(32, 80);
//emitter.width = 700;
//emitter.makeParticles('carrot', 100, false, 1);
//emitter.gravity = 150;
//emitter.bounce = 0.8;
//emitter.start(false, 20, 0.05);
}
function update() {
// Collide everything with the map
//map.collide();
marker.x = game.math.snapToFloor(game.input.getWorldX(), 16);
marker.y = game.math.snapToFloor(game.input.getWorldY(), 16);
if(game.input.mousePointer.isDown) {
map.putTile(marker.x, marker.y, 32);
}
}
})();

View file

@ -0,0 +1,60 @@
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
game.load.text('platform', 'assets/maps/mapdraw.json');
game.load.image('tiles', 'assets/tiles/platformer_tiles.png');
game.load.image('carrot', 'assets/sprites/carrot.png');
game.load.start();
}
var map: Phaser.Tilemap;
var emitter: Phaser.Emitter;
var marker: Phaser.Sprite;
function create() {
map = game.add.tilemap('tiles', 'platform', Phaser.Tilemap.FORMAT_TILED_JSON);
map.setCollisionRange(21,53);
map.setCollisionRange(105,109);
game.camera.texture.opaque = true;
game.camera.texture.backgroundColor = 'rgb(47,154,204)';
marker = game.add.sprite(0, 0);
marker.texture.width = 16;
marker.texture.height = 16;
marker.texture.opaque = true;
marker.texture.backgroundColor = 'rgba(255,0,0,0.4)';
//emitter = game.add.emitter(32, 80);
//emitter.width = 700;
//emitter.makeParticles('carrot', 100, false, 1);
//emitter.gravity = 150;
//emitter.bounce = 0.8;
//emitter.start(false, 20, 0.05);
}
function update() {
// Collide everything with the map
//map.collide();
marker.x = game.math.snapToFloor(game.input.getWorldX(), 16);
marker.y = game.math.snapToFloor(game.input.getWorldY(), 16);
if (game.input.mousePointer.isDown)
{
map.putTile(marker.x, marker.y, 32);
}
}
})();

View file

@ -0,0 +1,34 @@
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Tiled Tilemap Test
// First we load our map data (a json file exported from the map editor Tiled)
// This data file has several layers within it. Phaser will render them all.
game.load.text('jsontest', 'assets/maps/multi-layer-test.json');
// Then we load the actual tile sheet image
game.load.image('jsontiles', 'assets/tiles/platformer_tiles.png');
game.load.start();
}
var map;
function create() {
// This creates the tilemap using the json data and tile sheet we loaded.
// We tell it to use the Tiled JSON format parser.
map = game.add.tilemap('jsontiles', 'jsontest', Phaser.Tilemap.FORMAT_TILED_JSON);
//map.currentLayer.
}
function update() {
// Simple camera controls
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
game.camera.x -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
game.camera.x += 4;
}
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
game.camera.y -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
game.camera.y += 4;
}
}
})();

View file

@ -0,0 +1,58 @@
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Tiled Tilemap Test
// First we load our map data (a json file exported from the map editor Tiled)
// This data file has several layers within it. Phaser will render them all.
game.load.text('jsontest', 'assets/maps/multi-layer-test.json');
// Then we load the actual tile sheet image
game.load.image('jsontiles', 'assets/tiles/platformer_tiles.png');
game.load.start();
}
var map: Phaser.Tilemap;
function create() {
// This creates the tilemap using the json data and tile sheet we loaded.
// We tell it to use the Tiled JSON format parser.
map = game.add.tilemap('jsontiles', 'jsontest', Phaser.Tilemap.FORMAT_TILED_JSON);
//map.currentLayer.
}
function update() {
// Simple camera controls
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += 4;
}
}
})();

View file

@ -0,0 +1,32 @@
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Tiled Tilemap Test
// First we load our map data (a json file exported from the map editor Tiled)
game.load.text('jsontest', 'assets/maps/test.json');
//myGame.loader.addTextFile('jsontest', 'assets/maps/multi-layer-test.json');
// Then we load the actual tile sheet image
game.load.image('jsontiles', 'assets/tiles/platformer_tiles.png');
game.load.start();
}
function create() {
// This creates the tilemap using the json data and tile sheet we loaded.
// We tell it to use the Tiled JSON format parser.
game.add.tilemap('jsontiles', 'jsontest', Phaser.Tilemap.FORMAT_TILED_JSON);
}
function update() {
// Simple camera controls
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
game.camera.x -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
game.camera.x += 4;
}
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
game.camera.y -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
game.camera.y += 4;
}
}
})();

View file

@ -0,0 +1,54 @@
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Tiled Tilemap Test
// First we load our map data (a json file exported from the map editor Tiled)
game.load.text('jsontest', 'assets/maps/test.json');
//myGame.loader.addTextFile('jsontest', 'assets/maps/multi-layer-test.json');
// Then we load the actual tile sheet image
game.load.image('jsontiles', 'assets/tiles/platformer_tiles.png');
game.load.start();
}
function create() {
// This creates the tilemap using the json data and tile sheet we loaded.
// We tell it to use the Tiled JSON format parser.
game.add.tilemap('jsontiles', 'jsontest', Phaser.Tilemap.FORMAT_TILED_JSON);
}
function update() {
// Simple camera controls
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += 4;
}
}
})();

691
build/phaser.d.ts vendored
View file

@ -240,6 +240,10 @@ module Phaser {
*/
group: Group;
/**
* The name of the Game Object. Typically not set by Phaser, but extremely useful for debugging / logic.
*/
name: string;
/**
* x value of the object.
*/
x: number;
@ -2335,6 +2339,14 @@ module Phaser.Components.Sprite {
* Dispatched by the Input component when a pointer is released over an Input enabled sprite
*/
public onInputUp: Signal;
/**
* Dispatched by the Input component when the Sprite starts being dragged
*/
public onDragStart: Signal;
/**
* Dispatched by the Input component when the Sprite stops being dragged
*/
public onDragStop: Signal;
public onOutOfBounds: Signal;
}
}
@ -3049,8 +3061,8 @@ module Phaser.Physics.Shapes {
module Phaser.Physics {
class Body {
constructor(sprite: Sprite, type: number, x?: number, y?: number, shapeType?: number);
public toString(): string;
private _tempVec2;
private _fixedRotation;
/**
* Reference to Phaser.Game
*/
@ -3076,7 +3088,18 @@ module Phaser.Physics {
* @type {number}
*/
public type: number;
/**
* The angle of the body in radians. Used by all of the internal physics methods.
*/
public angle: number;
/**
* The rotation of the body in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
*/
/**
* Set the rotation of the body in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
* The value is automatically wrapped to be between 0 and 360.
*/
public rotation : number;
public transform: Transform;
public centroid: Vec2;
public position: Vec2;
@ -3098,7 +3121,6 @@ module Phaser.Physics {
public massInverted: number;
public inertia: number;
public inertiaInverted: number;
public fixedRotation: bool;
public categoryBits: number;
public maskBits: number;
public stepCount: number;
@ -3117,13 +3139,13 @@ module Phaser.Physics {
public removeShape(shape): void;
private setMass(mass);
private setInertia(inertia);
public setTransform(pos, angle): void;
public setTransform(pos: Vec2, angle: number): void;
public syncTransform(): void;
public getWorldPoint(p: Vec2): Vec2;
public getWorldVector(v: Vec2): Vec2;
public getLocalPoint(p: Vec2): Vec2;
public getLocalVector(v: Vec2): Vec2;
public setFixedRotation(flag): void;
public fixedRotation : bool;
public resetMassData(): void;
public resetJointAnchors(): void;
public cacheData(source?: string): void;
@ -3141,6 +3163,7 @@ module Phaser.Physics {
public isAwake : bool;
public awake(flag): void;
public isCollidable(other: Body): bool;
public toString(): string;
}
}
/**
@ -3155,7 +3178,7 @@ module Phaser {
* @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 [bodyType] {number} The physics body type of the object (defaults to BODY_DISABLED)
* @param [bodyType] {number} The physics body type of the object (defaults to BODY_DISABLED, i.e. no physics)
* @param [shapeType] {number} The physics shape the body will consist of (either Box (0) or Circle (1), for custom types see body.addShape)
*/
constructor(game: Game, x?: number, y?: number, key?: string, frame?, bodyType?: number, shapeType?: number);
@ -3168,6 +3191,10 @@ module Phaser {
*/
public type: number;
/**
* The name of game object.
*/
public name: string;
/**
* The Group this Sprite belongs to.
*/
public group: Group;
@ -3486,6 +3513,11 @@ module Phaser.Components {
*/
public renderRotation: bool;
/**
* The direction the animation frame is facing (can be Phaser.Types.RIGHT, LEFT, UP, DOWN).
* Very useful when hooking animation to Sprite directions.
*/
public facing: number;
/**
* Flip the graphic horizontally (defaults to false)
* @type {boolean}
*/
@ -5661,6 +5693,7 @@ module Phaser {
public to(properties, duration?: number, ease?: any, autoStart?: bool, delay?: number, loop?: bool, yoyo?: bool): Tween;
public loop(value: bool): Tween;
public yoyo(value: bool): Tween;
public isRunning: bool;
/**
* Start to tween.
*/
@ -6065,31 +6098,6 @@ module Phaser {
* @param tileHeight {number} Height of tiles in this map.
*/
constructor(game: Game, parent: Tilemap, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number);
/**
* Local private reference to game.
*/
private _game;
/**
* The tilemap that contains this layer.
* @type {Tilemap}
*/
private _parent;
/**
* Tileset of this layer.
*/
private _texture;
private _tileOffsets;
private _startX;
private _startY;
private _maxX;
private _maxY;
private _tx;
private _ty;
private _dx;
private _dy;
private _oldCameraX;
private _oldCameraY;
private _columnData;
private _tempTileX;
private _tempTileY;
private _tempTileW;
@ -6097,26 +6105,33 @@ module Phaser {
private _tempTileBlock;
private _tempBlockResults;
/**
* Local private reference to game.
*/
public game: Game;
/**
* The tilemap that contains this layer.
* @type {Tilemap}
*/
public parent: Tilemap;
/**
* The texture used to render the Sprite.
*/
public texture: Components.Texture;
/**
* The Sprite transform component.
*/
public transform: Components.Transform;
public tileOffsets;
/**
* The alpha of the Sprite between 0 and 1, a value of 1 being fully opaque.
*/
public alpha: number;
/**
* Name of this layer, so you can get this layer by its name.
* @type {string}
*/
public name: string;
/**
* A reference to the Canvas this GameObject will render to
* @type {HTMLCanvasElement}
*/
public canvas: HTMLCanvasElement;
/**
* A reference to the Canvas Context2D this GameObject will render to
* @type {CanvasRenderingContext2D}
*/
public context: CanvasRenderingContext2D;
/**
* Opacity of this layer.
* @type {number}
*/
public alpha: number;
/**
* Controls whether update() and draw() are automatically called.
* @type {boolean}
*/
@ -6127,10 +6142,6 @@ module Phaser {
*/
public visible: bool;
/**
* @type {string}
*/
public orientation: string;
/**
* Properties of this map layer. (normally set by map editors)
*/
public properties: {};
@ -6282,18 +6293,9 @@ module Phaser {
public updateBounds(): void;
/**
* Parse tile offsets from map data.
* @return {number} length of _tileOffsets array.
* @return {number} length of tileOffsets array.
*/
public parseTileOffsets(): number;
public renderDebugInfo(x: number, y: number, color?: string): void;
/**
* Render this layer to a specific camera with offset to camera.
* @param camera {Camera} The camera the layer is going to be rendered.
* @param dx {number} X offset to the camera.
* @param dy {number} Y offset to the camera.
* @return {boolean} Return false if layer is invisible or has a too low opacity(will stop rendering), return true if succeed.
*/
public render(camera: Camera, dx, dy): bool;
}
}
/**
@ -6439,6 +6441,14 @@ module Phaser {
*/
public type: number;
/**
* The name of game object.
*/
public name: string;
/**
* The Group this Sprite belongs to.
*/
public group: Group;
/**
* Controls if both <code>update</code> and render are called by the core game loop.
*/
public exists: bool;
@ -6451,10 +6461,26 @@ module Phaser {
*/
public visible: bool;
/**
*
* A useful state for many game objects. Kill and revive both flip this switch.
*/
public alive: bool;
/**
* The texture used to render the Sprite.
*/
public texture: Components.Texture;
/**
* The Sprite transform component.
*/
public transform: Components.Transform;
/**
* z order value of the object.
*/
public z: number;
/**
* Render iteration counter
*/
public renderOrderID: number;
/**
* Tilemap data format enum: CSV.
* @type {number}
*/
@ -6499,21 +6525,11 @@ module Phaser {
*/
public mapFormat: number;
/**
* An Array of Cameras to which this GameObject won't render
* @type {Array}
*/
public cameraBlacklist: number[];
/**
* Inherited update method.
* Inherited methods for overriding.
*/
public preUpdate(): void;
public update(): void;
/**
* Render this tilemap to a specific camera with specific offset.
* @param camera {Camera} The camera this tilemap will be rendered to.
* @param cameraOffsetX {number} X offset of the camera.
* @param cameraOffsetY {number} Y offset of the camera.
*/
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
public postUpdate(): void;
/**
* Parset csv map data and generate tiles.
* @param data {string} CSV map data.
@ -8122,6 +8138,118 @@ module Phaser {
* TODO: interpolate & polar
*/
module Phaser {
class PointUtils {
/**
* Adds the coordinates of two points together to create a new point.
* @method add
* @param {Point} a - The first Point object.
* @param {Point} b - The second Point object.
* @param {Point} out - Optional Point to store the value in, if not supplied a new Point object will be created.
* @return {Point} The new Point object.
**/
static add(a: Point, b: Point, out?: Point): Point;
/**
* Subtracts the coordinates of two points to create a new point.
* @method subtract
* @param {Point} a - The first Point object.
* @param {Point} b - The second Point object.
* @param {Point} out - Optional Point to store the value in, if not supplied a new Point object will be created.
* @return {Point} The new Point object.
**/
static subtract(a: Point, b: Point, out?: Point): Point;
/**
* Multiplies the coordinates of two points to create a new point.
* @method subtract
* @param {Point} a - The first Point object.
* @param {Point} b - The second Point object.
* @param {Point} out - Optional Point to store the value in, if not supplied a new Point object will be created.
* @return {Point} The new Point object.
**/
static multiply(a: Point, b: Point, out?: Point): Point;
/**
* Divides the coordinates of two points to create a new point.
* @method subtract
* @param {Point} a - The first Point object.
* @param {Point} b - The second Point object.
* @param {Point} out - Optional Point to store the value in, if not supplied a new Point object will be created.
* @return {Point} The new Point object.
**/
static divide(a: Point, b: Point, out?: Point): Point;
/**
* Clamps the Point object values to be between the given min and max
* @method clamp
* @param {Point} a - The point.
* @param {number} The minimum value to clamp this Point to
* @param {number} The maximum value to clamp this Point to
* @return {Point} This Point object.
**/
static clamp(a: Point, min: number, max: number): Point;
/**
* Clamps the x value of the given Point object to be between the min and max values.
* @method clampX
* @param {Point} a - The point.
* @param {number} The minimum value to clamp this Point to
* @param {number} The maximum value to clamp this Point to
* @return {Point} This Point object.
**/
static clampX(a: Point, min: number, max: number): Point;
/**
* Clamps the y value of the given Point object to be between the min and max values.
* @method clampY
* @param {Point} a - The point.
* @param {number} The minimum value to clamp this Point to
* @param {number} The maximum value to clamp this Point to
* @return {Point} This Point object.
**/
static clampY(a: Point, min: number, max: number): Point;
/**
* Creates a copy of the given Point.
* @method clone
* @param {Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
* @return {Point} The new Point object.
**/
static clone(a: Point, output?: Point): Point;
/**
* Returns the distance between the two given Point objects.
* @method distanceBetween
* @param {Point} a - The first Point object.
* @param {Point} b - The second Point object.
* @param {Boolean} round - Round the distance to the nearest integer (default false)
* @return {Number} The distance between the two Point objects.
**/
static distanceBetween(a: Point, b: Point, round?: bool): number;
/**
* Determines whether the two given Point objects are equal. They are considered equal if they have the same x and y values.
* @method equals
* @param {Point} a - The first Point object.
* @param {Point} b - The second Point object.
* @return {Boolean} A value of true if the Points are equal, otherwise false.
**/
static equals(a: Point, b: Point): bool;
/**
* Rotates a Point around the x/y coordinates given to the desired angle.
* @param a {Point} The Point object to rotate.
* @param x {number} The x coordinate of the anchor point
* @param y {number} The y coordinate of the anchor point
* @param {Number} angle The angle in radians (unless asDegrees is true) to rotate the Point to.
* @param {Boolean} asDegrees Is the given rotation in radians (false) or degrees (true)?
* @param {Number} distance An optional distance constraint between the Point and the anchor.
* @return The modified point object
*/
static rotate(a: Point, x: number, y: number, angle: number, asDegrees?: bool, distance?: number): Point;
/**
* Rotates a Point around the given Point to the desired angle.
* @param a {Point} The Point object to rotate.
* @param b {Point} The Point object to serve as point of rotation.
* @param x {number} The x coordinate of the anchor point
* @param y {number} The y coordinate of the anchor point
* @param {Number} angle The angle in radians (unless asDegrees is true) to rotate the Point to.
* @param {Boolean} asDegrees Is the given rotation in radians (false) or degrees (true)?
* @param {Number} distance An optional distance constraint between the Point and the anchor.
* @return The modified point object
*/
static rotateAroundPoint(a: Point, b: Point, angle: number, asDegrees?: bool, distance?: number): Point;
}
}
/**
* Phaser - Pointer
@ -9246,8 +9374,15 @@ module Phaser {
private _dh;
private _fx;
private _fy;
private _tx;
private _ty;
private _sin;
private _cos;
private _maxX;
private _maxY;
private _startX;
private _startY;
private _columnData;
private _cameraList;
private _camera;
private _groupLength;
@ -9279,6 +9414,11 @@ module Phaser {
*/
public renderSprite(camera: Camera, sprite: Sprite): bool;
public renderScrollZone(camera: Camera, scrollZone: ScrollZone): bool;
/**
* Render a tilemap to a specific camera.
* @param camera {Camera} The camera this tilemap will be rendered to.
*/
public renderTilemap(camera: Camera, tilemap: Tilemap): bool;
}
}
/**
@ -9309,6 +9449,7 @@ module Phaser {
*/
static renderPhysicsBodyInfo(body: Physics.Body, x: number, y: number, color?: string): void;
static renderSpriteBounds(sprite: Sprite, camera?: Camera, color?: string): void;
static renderRectangle(rect: Rectangle, fillStyle?: string): void;
static renderPhysicsBody(body: Physics.Body, lineWidth?: number, fillStyle?: string, sleepStyle?: string): void;
}
}
@ -9551,110 +9692,6 @@ module Phaser {
}
}
/**
* Phaser - State
*
* This is a base State class which can be extended if you are creating your game using TypeScript.
*/
module Phaser {
class State {
/**
* State constructor
* Create a new <code>State</code>.
*/
constructor(game: Game);
/**
* Reference to Game.
*/
public game: Game;
/**
* Currently used camera.
* @type {Camera}
*/
public camera: Camera;
/**
* Reference to the assets cache.
* @type {Cache}
*/
public cache: Cache;
/**
* Reference to the GameObject Factory.
* @type {GameObjectFactory}
*/
public add: GameObjectFactory;
/**
* Reference to the input manager
* @type {Input}
*/
public input: Input;
/**
* Reference to the assets loader.
* @type {Loader}
*/
public load: Loader;
/**
* Reference to the math helper.
* @type {GameMath}
*/
public math: GameMath;
/**
* Reference to the motion helper.
* @type {Motion}
*/
public motion: Motion;
/**
* Reference to the sound manager.
* @type {SoundManager}
*/
public sound: SoundManager;
/**
* Reference to the stage.
* @type {Stage}
*/
public stage: Stage;
/**
* Reference to game clock.
* @type {Time}
*/
public time: Time;
/**
* Reference to the tween manager.
* @type {TweenManager}
*/
public tweens: TweenManager;
/**
* Reference to the world.
* @type {World}
*/
public world: World;
/**
* Override this method to add some load operations.
* If you need to use the loader, you may need to use them here.
*/
public init(): void;
/**
* This method is called after the game engine successfully switches states.
* Feel free to add any setup code here.(Do not load anything here, override init() instead)
*/
public create(): void;
/**
* Put update logic here.
*/
public update(): void;
/**
* Put render operations here.
*/
public render(): void;
/**
* This method will be called when game paused.
*/
public paused(): void;
/**
* This method will be called when the state is destroyed
*/
public destroy(): void;
}
}
/**
* Phaser - Components - Debug
*
*
@ -9835,104 +9872,6 @@ module Phaser {
}
}
/**
* Phaser - IntersectResult
*
* A light-weight result object to hold the results of an intersection. For when you need more than just true/false.
*/
module Phaser {
class IntersectResult {
/**
* Did they intersect or not?
* @property result
* @type {Boolean}
*/
public result: bool;
/**
* @property x
* @type {Number}
*/
public x: number;
/**
* @property y
* @type {Number}
*/
public y: number;
/**
* @property x1
* @type {Number}
*/
public x1: number;
/**
* @property y1
* @type {Number}
*/
public y1: number;
/**
* @property x2
* @type {Number}
*/
public x2: number;
/**
* @property y2
* @type {Number}
*/
public y2: number;
/**
* @property width
* @type {Number}
*/
public width: number;
/**
* @property height
* @type {Number}
*/
public height: number;
/**
*
* @method setTo
* @param {Number} x1
* @param {Number} y1
* @param {Number} [x2]
* @param {Number} [y2]
* @param {Number} [width]
* @param {Number} [height]
*/
public setTo(x1: number, y1: number, x2?: number, y2?: number, width?: number, height?: number): void;
}
}
/**
* Phaser - Mat3Utils
*
* A collection of methods useful for manipulating and performing operations on Mat3 objects.
*
*/
module Phaser {
class Mat3Utils {
/**
* Transpose the values of a Mat3
**/
static transpose(source: Mat3, dest?: Mat3): Mat3;
/**
* Inverts a Mat3
**/
static invert(source: Mat3): Mat3;
/**
* Calculates the adjugate of a Mat3
**/
static adjoint(source: Mat3): Mat3;
/**
* Calculates the adjugate of a Mat3
**/
static determinant(source: Mat3): number;
/**
* Multiplies two Mat3s
**/
static multiply(source: Mat3, b: Mat3): Mat3;
static fromQuaternion(): void;
static normalFromMat4(): void;
}
}
/**
* Phaser - CircleUtils
*
* A collection of methods useful for manipulating and comparing Circle objects.
@ -10016,6 +9955,38 @@ module Phaser {
}
}
/**
* Phaser - Mat3Utils
*
* A collection of methods useful for manipulating and performing operations on Mat3 objects.
*
*/
module Phaser {
class Mat3Utils {
/**
* Transpose the values of a Mat3
**/
static transpose(source: Mat3, dest?: Mat3): Mat3;
/**
* Inverts a Mat3
**/
static invert(source: Mat3): Mat3;
/**
* Calculates the adjugate of a Mat3
**/
static adjoint(source: Mat3): Mat3;
/**
* Calculates the adjugate of a Mat3
**/
static determinant(source: Mat3): number;
/**
* Multiplies two Mat3s
**/
static multiply(source: Mat3, b: Mat3): Mat3;
static fromQuaternion(): void;
static normalFromMat4(): void;
}
}
/**
* Phaser - PixelUtils
*
* A collection of methods useful for manipulating pixels.
@ -10036,3 +10007,173 @@ module Phaser {
static getPixel(key: string, x: number, y: number): number;
}
}
/**
* Phaser - IntersectResult
*
* A light-weight result object to hold the results of an intersection. For when you need more than just true/false.
*/
module Phaser {
class IntersectResult {
/**
* Did they intersect or not?
* @property result
* @type {Boolean}
*/
public result: bool;
/**
* @property x
* @type {Number}
*/
public x: number;
/**
* @property y
* @type {Number}
*/
public y: number;
/**
* @property x1
* @type {Number}
*/
public x1: number;
/**
* @property y1
* @type {Number}
*/
public y1: number;
/**
* @property x2
* @type {Number}
*/
public x2: number;
/**
* @property y2
* @type {Number}
*/
public y2: number;
/**
* @property width
* @type {Number}
*/
public width: number;
/**
* @property height
* @type {Number}
*/
public height: number;
/**
*
* @method setTo
* @param {Number} x1
* @param {Number} y1
* @param {Number} [x2]
* @param {Number} [y2]
* @param {Number} [width]
* @param {Number} [height]
*/
public setTo(x1: number, y1: number, x2?: number, y2?: number, width?: number, height?: number): void;
}
}
/**
* Phaser - State
*
* This is a base State class which can be extended if you are creating your game using TypeScript.
*/
module Phaser {
class State {
/**
* State constructor
* Create a new <code>State</code>.
*/
constructor(game: Game);
/**
* Reference to Game.
*/
public game: Game;
/**
* Currently used camera.
* @type {Camera}
*/
public camera: Camera;
/**
* Reference to the assets cache.
* @type {Cache}
*/
public cache: Cache;
/**
* Reference to the GameObject Factory.
* @type {GameObjectFactory}
*/
public add: GameObjectFactory;
/**
* Reference to the input manager
* @type {Input}
*/
public input: Input;
/**
* Reference to the assets loader.
* @type {Loader}
*/
public load: Loader;
/**
* Reference to the math helper.
* @type {GameMath}
*/
public math: GameMath;
/**
* Reference to the motion helper.
* @type {Motion}
*/
public motion: Motion;
/**
* Reference to the sound manager.
* @type {SoundManager}
*/
public sound: SoundManager;
/**
* Reference to the stage.
* @type {Stage}
*/
public stage: Stage;
/**
* Reference to game clock.
* @type {Time}
*/
public time: Time;
/**
* Reference to the tween manager.
* @type {TweenManager}
*/
public tweens: TweenManager;
/**
* Reference to the world.
* @type {World}
*/
public world: World;
/**
* Override this method to add some load operations.
* If you need to use the loader, you may need to use them here.
*/
public init(): void;
/**
* This method is called after the game engine successfully switches states.
* Feel free to add any setup code here.(Do not load anything here, override init() instead)
*/
public create(): void;
/**
* Put update logic here.
*/
public update(): void;
/**
* Put render operations here.
*/
public render(): void;
/**
* This method will be called when game paused.
*/
public paused(): void;
/**
* This method will be called when the state is destroyed
*/
public destroy(): void;
}
}

File diff suppressed because it is too large Load diff