Search the Community
Showing results for tags 'mouse pointer'.
-
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:
-
This example seems promising: http://phaser.io/examples/v2/input/pointer-over But I need to add additional code for each of my graphics object to detect which object is currently below the mouse pointer. Also It would be tricky if the graphics object is a composite of several other graphics sub-objects. How can I print in console the name of a graphical object which is below the mouse pointer at any given time? Some examples? Note: Can I use Phaser.Pointer.hitTest() function and how? Thanks
- 3 replies
-
- mouse input
- phaser 2.6.1
-
(and 2 more)
Tagged with: