Skip to content

Commit 5d40365

Browse files
committed
InputHandler.dragFromCenter will now work regardless of the anchor point of the Sprite.
1 parent 84df7bf commit 5d40365

9 files changed

Lines changed: 24 additions & 15 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Bug Fixes
7676
* ArcadePhysics.separate doesn't pass over to seperateX/Y if overlapOnly is true (fix #604)
7777
* ArcadePhysics.collideSpriteVsSprite checks if both objects have bodies before processing.
7878
* Debug.spriteBounds will now take the position of the camera into consideration when rendering the bounds (fix #603)
79+
* InputHandler.dragFromCenter will now work regardless of the anchor point of the Sprite.
7980

8081

8182
Updated:

build/custom/phaser-no-libs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Phaser - http://www.phaser.io
99
*
10-
* v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 04:17:15
10+
* v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 05:20:52
1111
*
1212
* By Richard Davey http://www.photonstorm.com @photonstorm
1313
*
@@ -14831,7 +14831,9 @@ Phaser.InputHandler.prototype = {
1483114831
{
1483214832
if (this.dragFromCenter)
1483314833
{
14834-
this.sprite.centerOn(pointer.x, pointer.y);
14834+
var bounds = this.sprite.getBounds();
14835+
this.sprite.x = pointer.x + (this.sprite.x - bounds.centerX);
14836+
this.sprite.y = pointer.y + (this.sprite.y - bounds.centerY);
1483514837
this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
1483614838
}
1483714839
else

build/custom/phaser-no-libs.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/phaser-no-physics.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Phaser - http://www.phaser.io
99
*
10-
* v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 04:17:15
10+
* v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 05:20:52
1111
*
1212
* By Richard Davey http://www.photonstorm.com @photonstorm
1313
*
@@ -9604,7 +9604,7 @@ PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
96049604
*
96059605
* Phaser - http://www.phaser.io
96069606
*
9607-
* v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 04:17:15
9607+
* v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 05:20:52
96089608
*
96099609
* By Richard Davey http://www.photonstorm.com @photonstorm
96109610
*
@@ -24428,7 +24428,9 @@ Phaser.InputHandler.prototype = {
2442824428
{
2442924429
if (this.dragFromCenter)
2443024430
{
24431-
this.sprite.centerOn(pointer.x, pointer.y);
24431+
var bounds = this.sprite.getBounds();
24432+
this.sprite.x = pointer.x + (this.sprite.x - bounds.centerX);
24433+
this.sprite.y = pointer.y + (this.sprite.y - bounds.centerY);
2443224434
this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
2443324435
}
2443424436
else

build/custom/phaser-no-physics.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/phaser.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Phaser - http://www.phaser.io
99
*
10-
* v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 04:17:15
10+
* v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 05:20:52
1111
*
1212
* By Richard Davey http://www.photonstorm.com @photonstorm
1313
*
@@ -9604,7 +9604,7 @@ PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
96049604
*
96059605
* Phaser - http://www.phaser.io
96069606
*
9607-
* v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 04:17:15
9607+
* v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 05:20:52
96089608
*
96099609
* By Richard Davey http://www.photonstorm.com @photonstorm
96109610
*
@@ -24428,7 +24428,9 @@ Phaser.InputHandler.prototype = {
2442824428
{
2442924429
if (this.dragFromCenter)
2443024430
{
24431-
this.sprite.centerOn(pointer.x, pointer.y);
24431+
var bounds = this.sprite.getBounds();
24432+
this.sprite.x = pointer.x + (this.sprite.x - bounds.centerX);
24433+
this.sprite.y = pointer.y + (this.sprite.y - bounds.centerY);
2443224434
this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
2443324435
}
2443424436
else

build/phaser.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/phaser.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/input/InputHandler.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,9 @@ Phaser.InputHandler.prototype = {
11181118
{
11191119
if (this.dragFromCenter)
11201120
{
1121-
this.sprite.centerOn(pointer.x, pointer.y);
1121+
var bounds = this.sprite.getBounds();
1122+
this.sprite.x = pointer.x + (this.sprite.x - bounds.centerX);
1123+
this.sprite.y = pointer.y + (this.sprite.y - bounds.centerY);
11221124
this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
11231125
}
11241126
else

0 commit comments

Comments
 (0)