mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 23:12:24 -05:00
Merge pull request #881 from sjhuang26/issue-gui1127-pen-trails
No pen trails when dragging
This commit is contained in:
commit
4fd7ba896a
2 changed files with 15 additions and 12 deletions
|
@ -181,14 +181,18 @@ class Scratch3PenBlocks {
|
||||||
* @param {RenderedTarget} target - the target which has moved.
|
* @param {RenderedTarget} target - the target which has moved.
|
||||||
* @param {number} oldX - the previous X position.
|
* @param {number} oldX - the previous X position.
|
||||||
* @param {number} oldY - the previous Y position.
|
* @param {number} oldY - the previous Y position.
|
||||||
|
* @param {boolean} isForce - whether the movement was forced.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onTargetMoved (target, oldX, oldY) {
|
_onTargetMoved (target, oldX, oldY, isForce) {
|
||||||
const penSkinId = this._getPenLayerID();
|
// Only move the pen if the movement isn't forced (ie. dragged).
|
||||||
if (penSkinId >= 0) {
|
if (!isForce) {
|
||||||
const penState = this._getPenState(target);
|
const penSkinId = this._getPenLayerID();
|
||||||
this.runtime.renderer.penLine(penSkinId, penState.penAttributes, oldX, oldY, target.x, target.y);
|
if (penSkinId >= 0) {
|
||||||
this.runtime.requestRedraw();
|
const penState = this._getPenState(target);
|
||||||
|
this.runtime.renderer.penLine(penSkinId, penState.penAttributes, oldX, oldY, target.x, target.y);
|
||||||
|
this.runtime.requestRedraw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ class RenderedTarget extends Target {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
this.emit(RenderedTarget.EVENT_TARGET_MOVED, this, oldX, oldY);
|
this.emit(RenderedTarget.EVENT_TARGET_MOVED, this, oldX, oldY, force);
|
||||||
this.runtime.requestTargetsUpdate(this);
|
this.runtime.requestTargetsUpdate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -864,11 +864,10 @@ class RenderedTarget extends Target {
|
||||||
*/
|
*/
|
||||||
postSpriteInfo (data) {
|
postSpriteInfo (data) {
|
||||||
const force = data.hasOwnProperty('force') ? data.force : null;
|
const force = data.hasOwnProperty('force') ? data.force : null;
|
||||||
if (data.hasOwnProperty('x')) {
|
const isXChanged = data.hasOwnProperty('x');
|
||||||
this.setXY(data.x, this.y, force);
|
const isYChanged = data.hasOwnProperty('y');
|
||||||
}
|
if (isXChanged || isYChanged) {
|
||||||
if (data.hasOwnProperty('y')) {
|
this.setXY(isXChanged ? data.x : this.x, isYChanged ? data.y : this.y, force);
|
||||||
this.setXY(this.x, data.y, force);
|
|
||||||
}
|
}
|
||||||
if (data.hasOwnProperty('direction')) {
|
if (data.hasOwnProperty('direction')) {
|
||||||
this.setDirection(data.direction);
|
this.setDirection(data.direction);
|
||||||
|
|
Loading…
Reference in a new issue