Jump to content

Unable to repick tile


Thorleon
 Share

Recommended Posts

Hi folks,

first time into Phaser, and so far so good except...

I have Tilemap with data from CSV, with one board checker. My goal is to have possibility to pick and set it to new playing field. 

With below snippet after one "pick and leave" it is not possible to pick him again.

    private _updateMarker(): void {
        this.pointer.x = this.playerLayer.getTileX(this.game.input.activePointer.worldX) * Constants.TILE_SIZE;
        this.pointer.y = this.playerLayer.getTileY(this.game.input.activePointer.worldY) * Constants.TILE_SIZE;

        if (this.game.input.mousePointer.isDown) {   
            if(this.currentTitle !== null) {
                this.map.putTile(this.currentTitle, this.playerLayer.getTileX(this.pointer.x), this.playerLayer.getTileY(this.pointer.y), this.playerLayer);
                this.map.removeTile(this.currentTitle.x, this.currentTitle.y, this.playerLayer);
                this.currentTitle = null;
            } else {
                this.currentTitle = this.map.getTile(this.pointer.x, this.pointer.y, this.playerLayer);
            }
        }
    }

So maybe you have some idea what is going wrong here :)

Thanks in advance!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...