Skip to content

Commit 4f2c26d

Browse files
committed
Fixed issue with Pointer speed not resetting and moved some more render methods to the Debug class.
1 parent 3038f6f commit 4f2c26d

7 files changed

Lines changed: 80 additions & 34 deletions

File tree

Phaser/components/sprite/Input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ module Phaser.Components.Sprite {
392392

393393
if (this.bringToTop)
394394
{
395-
this._parent.group.bringToTop(this._parent);
395+
this._parent.bringToTop();
396396
}
397397

398398
}
@@ -618,7 +618,7 @@ module Phaser.Components.Sprite {
618618

619619
if (this.bringToTop)
620620
{
621-
this._parent.group.bringToTop(this._parent);
621+
this._parent.bringToTop();
622622
}
623623

624624
this._parent.events.onDragStart.dispatch(this._parent, pointer);

Phaser/gameobjects/GameObjectFactory.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ module Phaser {
134134
return <Group> this._world.group.add(new Group(this._game, maxSize));
135135
}
136136

137-
138137
/**
139138
* Create a new Particle.
140139
*
@@ -207,6 +206,17 @@ module Phaser {
207206
return this._world.group.add(sprite);
208207
}
209208

209+
/**
210+
* Add an existing Group to the current world.
211+
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
212+
*
213+
* @param group The Group to add to the Game World
214+
* @return {Phaser.Group} The Group object
215+
*/
216+
public existingGroup(group: Group): Group {
217+
return this._world.group.add(group);
218+
}
219+
210220
/**
211221
* Add an existing Button to the current world.
212222
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.

Phaser/gameobjects/Sprite.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,18 @@ module Phaser {
237237

238238
}
239239

240+
/**
241+
* Brings this Sprite to the top of its current Group, if set.
242+
*/
243+
public bringToTop() {
244+
245+
if (this.group)
246+
{
247+
this.group.bringToTop(this);
248+
}
249+
250+
}
251+
240252
/**
241253
* The scale of the Sprite. A value of 1 is original scale. 0.5 is half size. 2 is double the size.
242254
* This is a reference to Sprite.transform.scale

Phaser/input/Input.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ module Phaser {
377377
**/
378378
public activePointer: Pointer = null;
379379

380+
public inputObjects = [];
381+
382+
public totalTrackedObjects: number = 0;
383+
380384
/**
381385
* The X coordinate of the most recently active pointer.
382386
* This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.
@@ -469,9 +473,6 @@ module Phaser {
469473

470474
}
471475

472-
public inputObjects = [];
473-
public totalTrackedObjects: number = 0;
474-
475476
/**
476477
* Adds a new game object to be tracked by the Input Manager. Called by the Sprite.Input component, should not usually be called directly.
477478
* @method addGameObject
@@ -536,7 +537,6 @@ module Phaser {
536537
if (this.pointer9) { this.pointer9.update(); }
537538
if (this.pointer10) { this.pointer10.update(); }
538539

539-
540540
}
541541

542542
/**
@@ -591,6 +591,11 @@ module Phaser {
591591

592592
}
593593

594+
public resetSpeed(x: number, y: number) {
595+
this._oldPosition.setTo(x, y);
596+
this.speed.setTo(0, 0);
597+
}
598+
594599
/**
595600
* Get the total number of inactive Pointers
596601
* @method totalInactivePointers

Phaser/input/Pointer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,9 @@ module Phaser {
337337
//this.game.input.y = this.y * this.game.input.scale.y;
338338
this.game.input.x = this.x;
339339
this.game.input.y = this.y;
340+
this.game.input.position.setTo(this.x, this.y);
340341
this.game.input.onDown.dispatch(this);
342+
this.game.input.resetSpeed(this.x, this.y);
341343
}
342344

343345
this._stateReset = false;

Phaser/utils/DebugUtils.ts

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ module Phaser {
6363
DebugUtils.context.fillText('Vert 3 x: ' + (body.shapes[0].tverts[2].x * 50) + ' y: ' + (body.shapes[0].tverts[2].y * 50), x, y + 84);
6464
DebugUtils.context.fillText('Vert 4 x: ' + (body.shapes[0].tverts[3].x * 50) + ' y: ' + (body.shapes[0].tverts[3].y * 50), x, y + 98);
6565

66-
/*
67-
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);
68-
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);
69-
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);
70-
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);
71-
*/
66+
/*
67+
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);
68+
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);
69+
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);
70+
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);
71+
*/
7272

7373
}
7474

@@ -104,6 +104,20 @@ module Phaser {
104104

105105
}
106106

107+
/**
108+
* Render text
109+
* @param x {number} X position of the debug info to be rendered.
110+
* @param y {number} Y position of the debug info to be rendered.
111+
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
112+
*/
113+
static renderText(text: string, x: number, y: number, color?: string = 'rgb(255,255,255)') {
114+
115+
DebugUtils.context.font = '16px Courier';
116+
DebugUtils.context.fillStyle = color;
117+
DebugUtils.context.fillText(text, x, y);
118+
119+
}
120+
107121
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)') {
108122

109123
for (var s = 0; s < body.shapesLength; s++)
@@ -114,35 +128,36 @@ module Phaser {
114128
{
115129
var verts = body.shapes[s].tverts;
116130

117-
// DebugUtils.context.moveTo(body.position.x * 50 + verts[0].x, body.position.y * 50 + verts[0].y);
131+
// DebugUtils.context.moveTo(body.position.x * 50 + verts[0].x, body.position.y * 50 + verts[0].y);
118132
DebugUtils.context.moveTo(verts[0].x * 50, verts[0].y * 50);
119133

120-
for (var i = 1; i < verts.length; i++) {
121-
// DebugUtils.context.lineTo(body.position.x * 50 + verts[i].x, body.position.y * 50 + verts[i].y);
134+
for (var i = 1; i < verts.length; i++)
135+
{
136+
// DebugUtils.context.lineTo(body.position.x * 50 + verts[i].x, body.position.y * 50 + verts[i].y);
122137
DebugUtils.context.lineTo(verts[i].x * 50, verts[i].y * 50);
123-
}
138+
}
124139

125-
// DebugUtils.context.lineTo(body.position.x * 50 + verts[0].x, body.position.y * 50 + verts[0].y);
140+
// DebugUtils.context.lineTo(body.position.x * 50 + verts[0].x, body.position.y * 50 + verts[0].y);
126141
DebugUtils.context.lineTo(verts[0].x * 50, verts[0].y * 50);
127142
}
128143
else if (body.shapes[s].type == Phaser.Physics.Manager.SHAPE_TYPE_CIRCLE)
129-
{
130-
var circle = <Phaser.Physics.Shapes.Circle> body.shapes[s];
131-
DebugUtils.context.arc(circle.tc.x * 50, circle.tc.y * 50, circle.radius * 50, 0, Math.PI * 2, false);
144+
{
145+
var circle = <Phaser.Physics.Shapes.Circle> body.shapes[s];
146+
DebugUtils.context.arc(circle.tc.x * 50, circle.tc.y * 50, circle.radius * 50, 0, Math.PI * 2, false);
132147
}
133148

134-
DebugUtils.context.closePath();
149+
DebugUtils.context.closePath();
135150

136-
if (body.isAwake)
137-
{
138-
DebugUtils.context.fillStyle = fillStyle;
139-
}
140-
else
141-
{
142-
DebugUtils.context.fillStyle = sleepStyle;
143-
}
151+
if (body.isAwake)
152+
{
153+
DebugUtils.context.fillStyle = fillStyle;
154+
}
155+
else
156+
{
157+
DebugUtils.context.fillStyle = sleepStyle;
158+
}
144159

145-
DebugUtils.context.fill();
160+
DebugUtils.context.fill();
146161

147162
}
148163

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ TODO:
6161
* Ability to layer another DOM object and have it controlled by the game somehow. Can then do stacked canvas effects.
6262
* Stage lost to mute
6363
* When game is paused Pointer shouldn't process targetObjects / change cursor
64-
65-
64+
* Need to limit touch priority of items in groups?
65+
* Bring to Top doesn't seem to respect the group they are in
66+
* Add crop support
6667

6768
V1.0.0
6869

@@ -158,7 +159,8 @@ V1.0.0
158159
* Dropped the StageScaleMode.setScreenSize iterations count from 40 down to 10 and document min body height to 2000px.
159160
* Added Phaser.Net for browser and network specific functions, currently includes query string parsing and updating methods.
160161
* Added a new CSS3 Filters component. Apply blur, grayscale, sepia, brightness, contrast, hue rotation, invert, opacity and saturate filters to the games stage.
161-
* Fixed the CircleUtils.contains and containsPoint methods
162+
* Fixed the CircleUtils.contains and containsPoint methods.
163+
* Fixed issue with Input.speed values being too high on touch events.
162164

163165

164166

0 commit comments

Comments
 (0)