I am working on a game using tilemap and phaser framework. I want select the multiple coordinates on tilemap using phaser (cursor) and then can be able to store into an array. Is this possible using phaser? suggest me some solution for this.
Asked
Active
Viewed 99 times
0
-
Could you be more specific? When selecting multiple coordinates do you mean the objects created in the tilemap? Or do you just want the position (x, y) to be stored where you click? – Julián Apr 11 '17 at 19:47
-
Sorry for delay in reply. Actually, I want to store the selected coordinates (x,y position)whenever I am clicking on the the tilemap. – Ashish Apr 18 '17 at 04:30
1 Answers
0
You could work directly on game and get each position of the scene. You can try this:
var positions = [],
text;
function create() {
text = game.add.text(game.world.centerX / 2, game.world.centerY / 2, '', { fill: '#ffffff' });
game.input.onDown.add(function(pointer, event) {
listener();
}, this);
}
function update() {
}
function listener() {
var p = [game.input.mousePointer.x, game.input.mousePointer.y];
positions.push(p);
text.text = "You clicked in position: " + p;
console.log(positions);
}

Julián
- 1,238
- 1
- 12
- 24