Jump to content

Interactive Map


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


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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