User prompt
Move player with cursor exact same time by moving cursor not when i click
User prompt
I can't move the player from its point!
User prompt
Please fix the bug: 'Uncaught TypeError: playerNode.containsPoint is not a function' in or related to this line: 'if (playerNode.containsPoint(obj.global)) {' Line Number: 69
User prompt
Make the player can be dragged by click in it and hold to move it any freely vertical up or down and horizontal right or left.
User prompt
Hold player to cursor when player clicked by mouse button and don't move it.
User prompt
Make the player drageable
User prompt
Please fix the bug: 'TypeError: game.getChildrenByType is not a function' in or related to this line: 'var mazeWalls = game.getChildrenByType(MazeWall);' Line Number: 64
User prompt
Please fix the bug: 'ReferenceError: MazeWall is not defined' in or related to this line: 'var mazeWalls = game.getChildrenByType(MazeWall);' Line Number: 56
User prompt
Add collision to the player to hold it and moving on the maze
User prompt
Remove player movment
User prompt
Make the player go to the clicked side from player point by moving smoothly to it; If click right go right If click down go down If click left go left If click up go up
User prompt
Make player go to the cursor point not the opposit
User prompt
don't move it far from cursor
User prompt
If clicked by cursor on the top side of player move it vertical straight to it. same for each direction
User prompt
If click down the player go down and same for other directions
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(playerNode, {' Line Number: 51 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make player go to cursor
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(playerNode, {' Line Number: 51 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the player go to the clicked directions
User prompt
Don't make it follow cursor
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(playerNode, {' Line Number: 55 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
If click any side from the player movz it to it
User prompt
Don't move it diagonal
User prompt
Increase speed for the player.
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(playerNode, {' Line Number: 61 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Define the MazeWall class var MazeWall = Container.expand(function () { var self = Container.call(this); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ //Declare method for handling move events on game. function handleMove(x, y, obj) { // If a node is being dragged if (dragNode) { // Move the node to the cursor position dragNode.x = x; dragNode.y = y; } else { // If no node is being dragged, move the player to the cursor position playerNode.x = x; playerNode.y = y; } } // Set its anchor and pivot point to top left (x: 0.0, y: 0.0). // Retrieve a non-attached LK asset named 'Background1'. var backgroundNode = LK.getAsset('Background1', { anchorX: 0.0, anchorY: 0.0, scaleX: 2048 / 1000, scaleY: 2732 / 1000, x: 0, y: 0 }); //Manually attach asset to element, rather than using self.attachAsset game.addChild(backgroundNode); ; // Retrieve a non-attached LK asset named 'player'. // Set its anchor and pivot point to top left (x: 0.0, y: 0.0). // Position it at the bottom right of the screen (x: 2048, y: 2732). var playerNode = LK.getAsset('player', { anchorX: 2.2, anchorY: 2.2, scaleX: 0.7, scaleY: 0.7, x: 2048, y: 2732 }); // Manually attach asset to element, rather than using self.attachAsset game.addChild(playerNode); // Add event listeners to handle player movement game.down = function (x, y, obj) { // Check if the player was clicked if (playerNode.getBounds().contains(obj.global.x, obj.global.y)) { // If so, start dragging the player dragNode = playerNode; } // Also call move handler right away to make effect instant. handleMove(x, y, obj); }; ; ; game.update = function () { // Check for collision with maze walls var mazeWalls = []; for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof MazeWall) { mazeWalls.push(game.children[i]); } } for (var i = 0; i < mazeWalls.length; i++) { if (playerNode.intersects(mazeWalls[i])) { // Stop player movement playerNode.vx = 0; playerNode.vy = 0; break; } } // Update player position playerNode.x += playerNode.vx; playerNode.y += playerNode.vy; }; //Mouse or touch up on game object game.up = function (x, y, obj) { // Stop dragging the node dragNode = null; };
===================================================================
--- original.js
+++ change.js
@@ -27,8 +27,12 @@
if (dragNode) {
// Move the node to the cursor position
dragNode.x = x;
dragNode.y = y;
+ } else {
+ // If no node is being dragged, move the player to the cursor position
+ playerNode.x = x;
+ playerNode.y = y;
}
}
// Set its anchor and pivot point to top left (x: 0.0, y: 0.0).
// Retrieve a non-attached LK asset named 'Background1'.
@@ -61,11 +65,11 @@
// Check if the player was clicked
if (playerNode.getBounds().contains(obj.global.x, obj.global.y)) {
// If so, start dragging the player
dragNode = playerNode;
- // Also call move handler right away to make effect instant.
- handleMove(x, y, obj);
}
+ // Also call move handler right away to make effect instant.
+ handleMove(x, y, obj);
};
;
;
game.update = function () {