hnabi94 Posted April 21, 2014 Share Posted April 21, 2014 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 More sharing options...
MadMonkey119 Posted April 22, 2014 Share Posted April 22, 2014 Hi, this example (blank tilemap) may be useful. It first adds an event for input down which calls the pickTile methodvar tileStrip = tileSelector.create(1, 1, 'ground_1x1');tileStrip.inputEnabled = true;tileStrip.events.onInputDown.add(pickTile, this);pickTilefunction 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 More sharing options...
Recommended Posts