reverse drag v3 and v4

This commit is contained in:
dev sp
2024-02-08 15:48:41 +00:00
parent c229800e73
commit 9fff1e4a29
3 changed files with 193 additions and 209 deletions

View File

@@ -465,7 +465,7 @@ import Layout from '../../layouts/Layout.astro';
const targetZoneBorders = [];
targetZones.forEach((targetZone) => {
const targetImage = this.add.image(targetZone.x, targetZone.y, targetZone.name).setAlpha(0);
const targetBorder = this.add.image(targetZone.x, targetZone.y, "border").setAlpha(0).setScale(borderScale);
const targetBorder = this.add.image(targetZone.x, targetZone.y, "border").setAlpha(0.2).setScale(borderScale);
targetZoneBorders.push(targetBorder);
targetZone.block = null;
}),
@@ -492,8 +492,8 @@ import Layout from '../../layouts/Layout.astro';
// newBlock.setPosition(targetZone.x - 50, targetZone.y - 50); //backgroundColor:`#FF0000`
const col = counter % 2;
const row = Math.floor(counter / 2);
// newBlock.setPosition(targetZone.x - col * (newBlock.width + 10), targetZone.y - row * (newBlock.height + 10));
newBlock.setPosition(targetZone.x - 50, targetZone.y - 50);
newBlock.setPosition(targetZone.x - 50, targetZone.y -50);
newBlock.disableInteractive();
targetZone.block = newBlock;
droppedBlocks.push(newBlock);
@@ -505,18 +505,19 @@ import Layout from '../../layouts/Layout.astro';
droppedOnTargetZone = true;
targetZoneBorders[targetIndex].setVisible(true);
targetZoneBorders[targetIndex].setAlpha(0);
targetZoneBorders[targetIndex].setAlpha(1);
return;
}
});
if (!droppedOnTargetZone) {
newBlock.setPosition(newBlock.input.dragStartX, newBlock.input.dragStartY);
}
};
// Check if all blocks have been dropped on target zones
if (droppedBlocks.length === targetZones.length) {
displayResult(droppedBlocks);
newBlock.setVisible(false);
}
});