User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'x')' in or related to this line: 'var offsetX = draggedArea.x - 2048 / 2;' Line Number: 120
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'x')' in or related to this line: 'var offsetX = draggedArea.x - 2048 / 2;' Line Number: 65
User prompt
Add tween plugin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'x')' in or related to this line: 'var offsetX = draggedArea.x - 2048 / 2;' Line Number: 63
User prompt
Let greenareas move smoothly when i dragge it ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add dragge to the greenareas then sync them together
User prompt
surround the original greenarea from its corner too.
User prompt
Let the greenareas be outcorners not outside corners like between the sides.
User prompt
Add in it corners too.
User prompt
Add duplications around it
User prompt
Add greenarea to the middle of screen
User prompt
Add it to the game
Code edit (1 edits merged)
Please save this source code
User prompt
Make the drage can be anytime not just once
User prompt
Add dragge for greenareas and sync them to move togather by any greenarea.
User prompt
If i dragge any greenarea move the other greenareas with it only.
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'visible')' in or related to this line: 'return entity.entityGraphics.visible;' Line Number: 439
User prompt
Make continuously dragging even after all grey objects are invisible!
User prompt
Sync it all togather to move dragging any greenarea smoothly.
User prompt
Move it with dragged greenarea only.
User prompt
Don't teleport it move it with cursor in exact same time.
User prompt
Sync all the greenareas to move with any green area when i dragge its image.
User prompt
Make it can be dragged from any point of any greenarea object
User prompt
Add dragge to greenarea and its duplications
User prompt
Add the dragge again to the greenarea to move all togather
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x51ff00 }); /**** * Game Code ****/ // Create a new instance of the greenarea asset var greenArea = LK.getAsset('greenarea', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Add the greenarea to the game game.addChild(greenArea); // Add drag functionality to greenArea var dragNode = null; greenArea.down = function (x, y, obj) { dragNode = greenArea; }; greenArea.up = function (x, y, obj) { dragNode = null; }; greenArea.move = function (x, y, obj) { if (dragNode) { tween(dragNode, { x: x, y: y }, { duration: 300, easing: tween.easeInOut, onFinish: function onFinish() { syncGreenAreas(dragNode); } }); } }; // Function to synchronize all green areas function syncGreenAreas(draggedArea) { var offsetX = draggedArea.x - 2048 / 2; var offsetY = draggedArea.y - 2732 / 2; greenAreaTop.x = 2048 / 2 + offsetX; greenAreaTop.y = 2732 / 2 - 500 + offsetY; greenAreaBottom.x = 2048 / 2 + offsetX; greenAreaBottom.y = 2732 / 2 + 500 + offsetY; greenAreaBottomLeft.x = 2048 / 2 - 500 + offsetX; greenAreaBottomLeft.y = 2732 / 2 + 500 + offsetY; greenAreaBottomRight.x = 2048 / 2 + 500 + offsetX; greenAreaBottomRight.y = 2732 / 2 + 500 + offsetY; greenAreaLeft.x = 2048 / 2 - 500 + offsetX; greenAreaLeft.y = 2732 / 2 + offsetY; greenAreaTopLeft.x = 2048 / 2 - 500 + offsetX; greenAreaTopLeft.y = 2732 / 2 - 500 + offsetY; greenAreaRight.x = 2048 / 2 + 500 + offsetX; greenAreaRight.y = 2732 / 2 + offsetY; greenAreaTopRight.x = 2048 / 2 + 500 + offsetX; greenAreaTopRight.y = 2732 / 2 - 500 + offsetY; } // Create duplications of greenArea var greenAreaTop = LK.getAsset('greenarea', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 500 }); game.addChild(greenAreaTop); var greenAreaBottom = LK.getAsset('greenarea', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 500 }); game.addChild(greenAreaBottom); var greenAreaBottomLeft = LK.getAsset('greenarea', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 - 500, y: 2732 / 2 + 500 }); game.addChild(greenAreaBottomLeft); var greenAreaBottomRight = LK.getAsset('greenarea', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 + 500, y: 2732 / 2 + 500 }); game.addChild(greenAreaBottomRight); var greenAreaLeft = LK.getAsset('greenarea', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 - 500, y: 2732 / 2 }); game.addChild(greenAreaLeft); var greenAreaTopLeft = LK.getAsset('greenarea', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 - 500, y: 2732 / 2 - 500 }); game.addChild(greenAreaTopLeft); var greenAreaRight = LK.getAsset('greenarea', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 + 500, y: 2732 / 2 }); game.addChild(greenAreaRight); var greenAreaTopRight = LK.getAsset('greenarea', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 + 500, y: 2732 / 2 - 500 }); game.addChild(greenAreaTopRight);
===================================================================
--- original.js
+++ change.js
@@ -1,5 +1,10 @@
/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x51ff00
@@ -26,11 +31,18 @@
dragNode = null;
};
greenArea.move = function (x, y, obj) {
if (dragNode) {
- dragNode.x = x;
- dragNode.y = y;
- syncGreenAreas(dragNode);
+ tween(dragNode, {
+ x: x,
+ y: y
+ }, {
+ duration: 300,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ syncGreenAreas(dragNode);
+ }
+ });
}
};
// Function to synchronize all green areas
function syncGreenAreas(draggedArea) {