Code edit (2 edits merged)
Please save this source code
User prompt
Here is the log: VM543:330 Operation dropped at 1024.7185094197591 1467.1076782226564 14:23:55.811 VM543:330 Checking tile at position: 0 0 14:23:55.811 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Checking tile at position: 0 0 14:23:55.812 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Checking tile at position: 0 0 14:23:55.812 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Checking tile at position: 0 0 14:23:55.812 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Checking tile at position: 0 0 14:23:55.812 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Checking tile at position: 0 0 14:23:55.812 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Operation button not above any tile Fix the drop code
User prompt
Here is the log: VM543:330 Operation dropped at 1024.7185094197591 1467.1076782226564 14:23:55.811 VM543:330 Checking tile at position: 0 0 14:23:55.811 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Checking tile at position: 0 0 14:23:55.812 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Checking tile at position: 0 0 14:23:55.812 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Checking tile at position: 0 0 14:23:55.812 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Checking tile at position: 0 0 14:23:55.812 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Checking tile at position: 0 0 14:23:55.812 VM543:330 Operation button is NOT above tile at position: 0 0 14:23:55.812 VM543:330 Operation button not above any tile Fix the code
Code edit (1 edits merged)
Please save this source code
User prompt
in ``` puzzleManager.board.forEach(function (tile) { if (dragNode.x >= tile.x - tile.width / 2 && dragNode.x <= tile.x + tile.width / 2 && dragNode.y >= tile.y - tile.height / 2 && dragNode.y <= tile.y + tile.height / 2) { puzzleManager.applyOperation(dragNode, tile); tileFound = true; } }); ``` add detailed logs because it doesn't work
Code edit (4 edits merged)
Please save this source code
User prompt
if Operation button not above any tile, move it smoothy to its base position
User prompt
in applyOperation, first check if operationButton is above a tile or not
User prompt
when droping an operation button, call applyOperation. in applyOperation, first check if operationButton is above a tile or not
User prompt
replace ``` operation.x = centerX + 600 + (i - (self.levelData.operations.length - 1) / 2) * 250; // Space buttons evenly operation.y = 2600; // Position near the bottom of the screen ``` by a setBasePosition function in operation buttons that sets both x,y and baseX,baseY
User prompt
store initial operation buttons position in properties baseX and baseY
Code edit (5 edits merged)
Please save this source code
User prompt
make drag anim duration depend on target x,y distance
Code edit (1 edits merged)
Please save this source code
User prompt
Ok, try to make operation buttons move smoother โช๐ก Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
ok, obj.target parameter isn't useful: it's only the main game object. Only use x and y parameters to dertermine if an operation button was tapped
User prompt
Still drag doesn't work. Still dragNode is null. Please refer to game.down documentation to determine how to use the object properly
User prompt
``` if (obj && obj.parent && obj.parent.constructor.name === 'OperationButton') { dragNode = obj.parent; } ``` Analyze more deeply, you'll find that obj is an event from game.down handler, it contains a target property.
User prompt
drageNode stay null when tapping operationButtons Fix drag code code if (obj && obj.parent instanceof OperationButton) { dragNode = obj.parent; } doesn't work: unsing parent or parent.parent is not the way to detect objects classes.
User prompt
code if (obj && obj.parent instanceof OperationButton) { dragNode = obj.parent; } doesn't work. drageNode stay null when tapping operationButtons
Code edit (8 edits merged)
Please save this source code
User prompt
in playing state handlers, make operation buttons draggable
User prompt
make operation buttons draggable
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -149,12 +149,8 @@
/****
* Game Code
****/
-var interTileOffsetX = -2;
-var dragNode = null;
-var interTileOffsetY = -0; // relative to interTileOffsetX
-var tileSize = LK.getAsset('hexTile', {}).width + interTileOffsetX;
/************************************* GAME OBJECTS CLASSES ************************************/
/***********************************************************************************************/
function PuzzleManager(game) {
var self = this;
@@ -596,8 +592,9 @@
var foregroundLayer;
var backgroundImage;
var centerX = 1024;
var centerY = 1366;
+var dragNode = null;
var tileColors = {
0: 0x16C47F,
// Bright Green
1: 0xF93827,
tick
Sound effect
tileEntrance
Sound effect
tileRemove
Sound effect
operationSelect
Sound effect
operationCancel
Sound effect
tileChangeValue
Sound effect
resetSound
Sound effect
levelFailed
Sound effect
menuLevelSelect
Sound effect
menuCellEnter
Sound effect
applause
Sound effect
bgMusic
Music
tada
Sound effect