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 <sprite>, but cannot be detected by other sprites while it is
being dragged.
This commit is contained in:
Paul Kaplan 2018-04-10 14:20:51 -04:00
parent d177f4cd0c
commit 92d00b5944

View file

@ -734,7 +734,11 @@ class RenderedTarget extends Target {
if (!firstClone || !this.renderer) { if (!firstClone || !this.renderer) {
return false; 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 <sprite>, 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( return this.renderer.isTouchingDrawables(
this.drawableID, drawableCandidates); this.drawableID, drawableCandidates);
} }