Jump to content

Interactive Map


hnabi94
 Share

Recommended Posts

Hello, I'm new to Phaser and I need some help. So I've managed to create a map on Tiled and then load it into a game, and I was wondering how can I tell if a player clicks on a certain tile on the map and then call a corresponding function. 

 

Thanks, hnabi94.

 

 

Link to comment
Share on other sites

Hi, this example (blank tilemap) may be useful.

 

It first adds an event for input down which calls the pickTile method

var tileStrip = tileSelector.create(1, 1, 'ground_1x1');tileStrip.inputEnabled = true;tileStrip.events.onInputDown.add(pickTile, this);

pickTile

function pickTile(sprite, pointer) {currentTile = game.math.snapToFloor(pointer.x, 32) / 32;}

You could then check what type of phaser.tile currentTile is then call a corresponding function with a switch.

 

Not entirely sure on that method and have only been using Phaser for the past 3 days but hopefully that's helpful.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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