Merge pull request #2335 from daikifukumori/fix/tilted-any-trigger

WeDo 2.0 isTilted-any function bug fix
This commit is contained in:
DD Liu 2020-05-22 23:31:42 -04:00 committed by GitHub
commit 32f87b3396
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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