Fixed issue with Pointer speed not resetting and moved some more render methods to the Debug class.

This commit is contained in:
Richard Davey
2013-07-29 00:43:10 +01:00
parent 3038f6fcf8
commit 4f2c26df77
7 changed files with 80 additions and 34 deletions
+2 -2
View File
@@ -392,7 +392,7 @@ module Phaser.Components.Sprite {
if (this.bringToTop)
{
this._parent.group.bringToTop(this._parent);
this._parent.bringToTop();
}
}
@@ -618,7 +618,7 @@ module Phaser.Components.Sprite {
if (this.bringToTop)
{
this._parent.group.bringToTop(this._parent);
this._parent.bringToTop();
}
this._parent.events.onDragStart.dispatch(this._parent, pointer);
+11 -1
View File
@@ -134,7 +134,6 @@ module Phaser {
return <Group> this._world.group.add(new Group(this._game, maxSize));
}
/**
* Create a new Particle.
*
@@ -207,6 +206,17 @@ module Phaser {
return this._world.group.add(sprite);
}
/**
* Add an existing Group to the current world.
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
*
* @param group The Group to add to the Game World
* @return {Phaser.Group} The Group object
*/
public existingGroup(group: Group): Group {
return this._world.group.add(group);
}
/**
* Add an existing Button to the current world.
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
+12
View File
@@ -237,6 +237,18 @@ module Phaser {
}
/**
* Brings this Sprite to the top of its current Group, if set.
*/
public bringToTop() {
if (this.group)
{
this.group.bringToTop(this);
}
}
/**
* The scale of the Sprite. A value of 1 is original scale. 0.5 is half size. 2 is double the size.
* This is a reference to Sprite.transform.scale
+9 -4
View File
@@ -377,6 +377,10 @@ module Phaser {
**/
public activePointer: Pointer = null;
public inputObjects = [];
public totalTrackedObjects: number = 0;
/**
* The X coordinate of the most recently active pointer.
* This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.
@@ -469,9 +473,6 @@ module Phaser {
}
public inputObjects = [];
public totalTrackedObjects: number = 0;
/**
* Adds a new game object to be tracked by the Input Manager. Called by the Sprite.Input component, should not usually be called directly.
* @method addGameObject
@@ -536,7 +537,6 @@ module Phaser {
if (this.pointer9) { this.pointer9.update(); }
if (this.pointer10) { this.pointer10.update(); }
}
/**
@@ -591,6 +591,11 @@ module Phaser {
}
public resetSpeed(x: number, y: number) {
this._oldPosition.setTo(x, y);
this.speed.setTo(0, 0);
}
/**
* Get the total number of inactive Pointers
* @method totalInactivePointers
+2
View File
@@ -337,7 +337,9 @@ module Phaser {
//this.game.input.y = this.y * this.game.input.scale.y;
this.game.input.x = this.x;
this.game.input.y = this.y;
this.game.input.position.setTo(this.x, this.y);
this.game.input.onDown.dispatch(this);
this.game.input.resetSpeed(this.x, this.y);
}
this._stateReset = false;
+39 -24
View File
@@ -63,12 +63,12 @@ module Phaser {
DebugUtils.context.fillText('Vert 3 x: ' + (body.shapes[0].tverts[2].x * 50) + ' y: ' + (body.shapes[0].tverts[2].y * 50), x, y + 84);
DebugUtils.context.fillText('Vert 4 x: ' + (body.shapes[0].tverts[3].x * 50) + ' y: ' + (body.shapes[0].tverts[3].y * 50), x, y + 98);
/*
DebugUtils.context.fillText('Vert 1 x: ' + body.shapes[0].verts[0].x.toFixed(1) + ' y: ' + body.shapes[0].verts[0].y.toFixed(1), x, y + 56);
DebugUtils.context.fillText('Vert 2 x: ' + body.shapes[0].verts[1].x.toFixed(1) + ' y: ' + body.shapes[0].verts[1].y.toFixed(1), x, y + 70);
DebugUtils.context.fillText('Vert 3 x: ' + body.shapes[0].verts[2].x.toFixed(1) + ' y: ' + body.shapes[0].verts[2].y.toFixed(1), x, y + 84);
DebugUtils.context.fillText('Vert 4 x: ' + body.shapes[0].verts[3].x.toFixed(1) + ' y: ' + body.shapes[0].verts[3].y.toFixed(1), x, y + 98);
*/
/*
DebugUtils.context.fillText('Vert 1 x: ' + body.shapes[0].verts[0].x.toFixed(1) + ' y: ' + body.shapes[0].verts[0].y.toFixed(1), x, y + 56);
DebugUtils.context.fillText('Vert 2 x: ' + body.shapes[0].verts[1].x.toFixed(1) + ' y: ' + body.shapes[0].verts[1].y.toFixed(1), x, y + 70);
DebugUtils.context.fillText('Vert 3 x: ' + body.shapes[0].verts[2].x.toFixed(1) + ' y: ' + body.shapes[0].verts[2].y.toFixed(1), x, y + 84);
DebugUtils.context.fillText('Vert 4 x: ' + body.shapes[0].verts[3].x.toFixed(1) + ' y: ' + body.shapes[0].verts[3].y.toFixed(1), x, y + 98);
*/
}
@@ -104,6 +104,20 @@ module Phaser {
}
/**
* Render text
* @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)
*/
static renderText(text: string, x: number, y: number, color?: string = 'rgb(255,255,255)') {
DebugUtils.context.font = '16px Courier';
DebugUtils.context.fillStyle = color;
DebugUtils.context.fillText(text, x, y);
}
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++)
@@ -114,35 +128,36 @@ module Phaser {
{
var verts = body.shapes[s].tverts;
// DebugUtils.context.moveTo(body.position.x * 50 + verts[0].x, body.position.y * 50 + verts[0].y);
// DebugUtils.context.moveTo(body.position.x * 50 + verts[0].x, body.position.y * 50 + verts[0].y);
DebugUtils.context.moveTo(verts[0].x * 50, verts[0].y * 50);
for (var i = 1; i < verts.length; i++) {
// DebugUtils.context.lineTo(body.position.x * 50 + verts[i].x, body.position.y * 50 + verts[i].y);
for (var i = 1; i < verts.length; i++)
{
// DebugUtils.context.lineTo(body.position.x * 50 + verts[i].x, body.position.y * 50 + verts[i].y);
DebugUtils.context.lineTo(verts[i].x * 50, verts[i].y * 50);
}
}
// DebugUtils.context.lineTo(body.position.x * 50 + verts[0].x, body.position.y * 50 + verts[0].y);
// DebugUtils.context.lineTo(body.position.x * 50 + verts[0].x, body.position.y * 50 + verts[0].y);
DebugUtils.context.lineTo(verts[0].x * 50, verts[0].y * 50);
}
else if (body.shapes[s].type == Phaser.Physics.Manager.SHAPE_TYPE_CIRCLE)
{
var circle = <Phaser.Physics.Shapes.Circle> body.shapes[s];
DebugUtils.context.arc(circle.tc.x * 50, circle.tc.y * 50, circle.radius * 50, 0, Math.PI * 2, false);
{
var circle = <Phaser.Physics.Shapes.Circle> body.shapes[s];
DebugUtils.context.arc(circle.tc.x * 50, circle.tc.y * 50, circle.radius * 50, 0, Math.PI * 2, false);
}
DebugUtils.context.closePath();
DebugUtils.context.closePath();
if (body.isAwake)
{
DebugUtils.context.fillStyle = fillStyle;
}
else
{
DebugUtils.context.fillStyle = sleepStyle;
}
if (body.isAwake)
{
DebugUtils.context.fillStyle = fillStyle;
}
else
{
DebugUtils.context.fillStyle = sleepStyle;
}
DebugUtils.context.fill();
DebugUtils.context.fill();
}
+5 -3
View File
@@ -61,8 +61,9 @@ TODO:
* Ability to layer another DOM object and have it controlled by the game somehow. Can then do stacked canvas effects.
* Stage lost to mute
* When game is paused Pointer shouldn't process targetObjects / change cursor
* Need to limit touch priority of items in groups?
* Bring to Top doesn't seem to respect the group they are in
* Add crop support
V1.0.0
@@ -158,7 +159,8 @@ V1.0.0
* Dropped the StageScaleMode.setScreenSize iterations count from 40 down to 10 and document min body height to 2000px.
* Added Phaser.Net for browser and network specific functions, currently includes query string parsing and updating methods.
* Added a new CSS3 Filters component. Apply blur, grayscale, sepia, brightness, contrast, hue rotation, invert, opacity and saturate filters to the games stage.
* Fixed the CircleUtils.contains and containsPoint methods
* Fixed the CircleUtils.contains and containsPoint methods.
* Fixed issue with Input.speed values being too high on touch events.