Multiselect tiles in tilemap using cursor

106 Views Asked by At

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.

1

There are 1 best solutions below

0
Julián On

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);
}