From f1fce036f02262359dcd2b3d0125edc58f06a225 Mon Sep 17 00:00:00 2001 From: "Michael \"Z\" Goddard" Date: Mon, 13 Aug 2018 14:53:00 -0400 Subject: [PATCH] round x and y like Scratch 2 does https://github.com/LLK/scratch-flash/blob/develop/src/scratch/ScratchSprite.as#L180-L186 Scratch 2 rounds the X and Y to the nearest whole number. --- src/sprites/rendered-target.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sprites/rendered-target.js b/src/sprites/rendered-target.js index 93ee08661..bf98a5202 100644 --- a/src/sprites/rendered-target.js +++ b/src/sprites/rendered-target.js @@ -272,8 +272,8 @@ class RenderedTarget extends Target { const oldY = this.y; if (this.renderer) { const position = this.renderer.getFencedPositionOfDrawable(this.drawableID, [x, y]); - position[0] = this._roundCoord(position[0], 8); - position[1] = this._roundCoord(position[1], 8); + position[0] = Math.round(position[0]); + position[1] = Math.round(position[1]); this.x = position[0]; this.y = position[1]; @@ -285,8 +285,8 @@ class RenderedTarget extends Target { this.runtime.requestRedraw(); } } else { - this.x = this._roundCoord(x, 8); - this.y = this._roundCoord(y, 8); + this.x = Math.round(x); + this.y = Math.round(y); } this.emit(RenderedTarget.EVENT_TARGET_MOVED, this, oldX, oldY, force); this.runtime.requestTargetsUpdate(this);