Merge pull request #1081 from paulkaplan/fix-stage-clicks

Activate stage click hats if no other sprites are clicked
This commit is contained in:
Paul Kaplan 2018-04-23 14:47:26 -04:00 committed by GitHub
commit f118e912bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,6 +44,12 @@ class Mouse {
return;
}
}
// If haven't returned, activate click hats for stage.
// Still using both blocks for sharing compatibility.
this.runtime.startHats('event_whenthisspriteclicked',
null, this.runtime.getTargetForStage());
this.runtime.startHats('event_whenstageclicked',
null, this.runtime.getTargetForStage());
}
}
@ -70,7 +76,10 @@ class Mouse {
}
if (typeof data.isDown !== 'undefined') {
this._isDown = data.isDown;
if (!this._isDown) {
// Make sure click is within the canvas bounds to activate click hats
if (!this._isDown &&
data.x > 0 && data.x < data.canvasWidth &&
data.y > 0 && data.y < data.canvasHeight) {
this._activateClickHats(data.x, data.y, data.wasDragged);
}
}