Search the Community
Showing results for tags 'cursor event'.
-
Hello devs, I am working on one game where I have created function to save onclicked coordinates into an array. function update() { marker.x = layer.getTileX(game.input.activePointer.pageX ) * 15; marker.y = layer.getTileY(game.input.activePointer.pageY ) * 15; var arrayData = []; if (game.input.mousePointer.isDown && map.getTile(layer.getTileX(marker.x), layer.getTileY(marker.y)) != currentTile) { arrayData.push(layer.getTileX(marker.x),layer.getTileY(marker.y)); arrayData.toString(); document.getElementById('test').innerHTML = " Data: " + arrayData; console.log("Data:"+arrayData); } In this function I have declared array var arrayData = []; inside update() function and the output is, it showing only showing on set of coordinates and second click that value is updating . So, coordinate values are added into array but only single pair and on every click that pair value is updating. Secondly, If I am declaring array outside the update function ,the result is totally different. On-clicked, the value are coming in high quantity. If I am clicking on (1,3) coordinates then the array result is (1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3) and on second click on the coordinates (4,6) the array result is like (1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6) Please suggest me some solution , so that I can add these coordinate pairs properly into an array. Thank you
- 6 replies
-
- tiled
- cursor event
-
(and 1 more)
Tagged with: