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
+5
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.
*/
+15 -2
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));
}
}
/**
+59 -27
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;