Skip to content

Commit 1294b3a

Browse files
committed
Input over now works regardless of rotation, anchor or scale.
1 parent 427819c commit 1294b3a

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

examples/buttons/button scale.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,13 @@ function create() {
5656

5757
// Scaled and Rotated button
5858
button6 = game.add.button(570, 200, 'button', changeSky, this, 2, 1, 0); // anchor 0.5
59-
// button6 = game.add.button(470, 100, 'button', changeSky, this, 2, 1, 0); // anchor 0
6059
button6.name = 'sky6';
6160
button6.angle = 32;
6261
button6.scale.setTo(2, 2);
6362
button6.anchor.setTo(0.5, 0.5);
6463

65-
66-
// game.world.setBounds(0, 0, 2000, 2000);
6764
// works regardless of world angle, parent angle or camera position
65+
// game.world.setBounds(0, 0, 2000, 2000);
6866
// game.world.angle = 10;
6967
// game.camera.x = 300;
7068

@@ -87,6 +85,7 @@ function render () {
8785

8886
// game.debug.renderWorldTransformInfo(button1, 32, 132);
8987
// game.debug.renderText('sx: ' + button3.scale.x + ' sy: ' + button3.scale.y + ' w: ' + button3.width + ' cw: ' + button3._cache.width, 32, 20);
90-
game.debug.renderPoint(button6.input._tempPoint);
88+
// game.debug.renderPoint(button2.input._tempPoint);
89+
// game.debug.renderPoint(button6.input._tempPoint);
9190

9291
}

src/gameobjects/Sprite.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,6 @@ Phaser.Sprite.prototype.updateBounds = function() {
524524
*/
525525
Phaser.Sprite.prototype.getLocalPosition = function(p, x, y, sx, sy) {
526526

527-
// p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * this.scale.x) + this._cache.a02;
528-
// p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * this.scale.y) + this._cache.a12;
529-
530527
p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * sx) + this._cache.a02;
531528
p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * sy) + this._cache.a12;
532529

@@ -549,8 +546,8 @@ Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, x, y) {
549546
p.y = this._cache.a00 * this._cache.idi * y + -this._cache.i10 * this._cache.idi * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.i10) * this._cache.idi;
550547

551548
// apply anchor
552-
p.x += (this.anchor.x * this.width);
553-
p.y += (this.anchor.y * this.height);
549+
p.x += (this.anchor.x * this._cache.width);
550+
p.y += (this.anchor.y * this._cache.height);
554551

555552
return p;
556553

0 commit comments

Comments
 (0)