From 92d00b5944a5ecac12701a2c960119ae6d74b1cf Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Tue, 10 Apr 2018 14:20:51 -0400 Subject: [PATCH] Filter out dragging targets from touching sprite check. This introduces an asymmetry that matches the Scratch 2 behavior, that is, a sprite that is being dragged can detect other sprites using touching , but cannot be detected by other sprites while it is being dragged. --- src/sprites/rendered-target.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sprites/rendered-target.js b/src/sprites/rendered-target.js index 35204ec93..b17f39734 100644 --- a/src/sprites/rendered-target.js +++ b/src/sprites/rendered-target.js @@ -734,7 +734,11 @@ class RenderedTarget extends Target { if (!firstClone || !this.renderer) { return false; } - const drawableCandidates = firstClone.sprite.clones.map(clone => clone.drawableID); + // Filter out dragging targets. This means a sprite that is being dragged + // can detect other sprites using touching , but cannot be detected + // by other sprites while it is being dragged. This matches Scratch 2.0 behavior. + const drawableCandidates = firstClone.sprite.clones.filter(clone => !clone.dragging) + .map(clone => clone.drawableID); return this.renderer.isTouchingDrawables( this.drawableID, drawableCandidates); }