Correct the trigger of isTilted()

This commit is contained in:
Daiki Fukumori 2020-03-11 22:15:20 +08:00
parent 772fbe1aab
commit 71631f5aa2

View file

@ -1543,8 +1543,8 @@ class Scratch3WeDo2Blocks {
_isTilted (direction) { _isTilted (direction) {
switch (direction) { switch (direction) {
case WeDo2TiltDirection.ANY: case WeDo2TiltDirection.ANY:
return (Math.abs(this._peripheral.tiltX) >= Scratch3WeDo2Blocks.TILT_THRESHOLD) || return (this._peripheral.tiltX > 45 ? 256 - this._peripheral.tiltX : this._peripheral.tiltX) >= Scratch3WeDo2Blocks.TILT_THRESHOLD ||
(Math.abs(this._peripheral.tiltY) >= Scratch3WeDo2Blocks.TILT_THRESHOLD); (this._peripheral.tiltY > 45 ? 256 - this._peripheral.tiltY : this._peripheral.tiltY) >= Scratch3WeDo2Blocks.TILT_THRESHOLD;
default: default:
return this._getTiltAngle(direction) >= Scratch3WeDo2Blocks.TILT_THRESHOLD; return this._getTiltAngle(direction) >= Scratch3WeDo2Blocks.TILT_THRESHOLD;
} }