seventheory Posted January 13, 2014 Share Posted January 13, 2014 Hi all, I am a new developer to Phaser, this framework is such a marvel to work with. Currently I am working on a slide scroller based (Mario-style) where the player can collect "weapons" and fire them at other players.And I would like for the projectiles to destroy any tiles that is in the way. Is it possible to set the "destructibility" of tiles? I have googled the relevant sites and played with the code in Brackets but no luck so far. Many thanks in advance. Sincerely,Xavier Link to comment Share on other sites More sharing options...
XekeDeath Posted January 13, 2014 Share Posted January 13, 2014 I'd probably set a bool flag on the tiles and check it in the collision handler between the projectiles and tiles.Or, if you want the projectiles to go through tiles, instead of striking them, use overlap instead of collide. Link to comment Share on other sites More sharing options...
jpdev Posted January 13, 2014 Share Posted January 13, 2014 After you have detected a collision, you can change the tile in the tilemap. You can see how to manipulate tiles in the tile map in this example. It boils down to this: map.putTile(0, x, y) Setting the tile to "0" removes it. You could also set it to some other tile. AlexArroyoDuque 1 Link to comment Share on other sites More sharing options...
Pert Posted January 13, 2014 Share Posted January 13, 2014 Assuming you might want to have multiple hits per tile, you can have 3-4 different "break" states, similar to jpdev's solution, then replace tiles from X to Z, to Y and then to 0 when it has been completely destroyed. Link to comment Share on other sites More sharing options...
seventheory Posted January 14, 2014 Author Share Posted January 14, 2014 Thanks guys,sorry for late reply, had high fever yesterday. Will try out the proposed solutions and give status update. Sincerely,Xavier Link to comment Share on other sites More sharing options...
Recommended Posts