Breno Pinheiro Posted April 5, 2016 Share Posted April 5, 2016 Hi, I am trying to create a platform game like Sonic using phaser, tilemap and physic. Using the examples that I found in Phaser official website, I can do the basic, like the hero walks and collides with the map. But I cant define the callbacks functions, like, for example, to get coins and died when the hero beats with a enemy. I would like a example how can I do this using the arcade and p2 physics class. Link to comment Share on other sites More sharing options...
drhayes Posted April 6, 2016 Share Posted April 6, 2016 If you're using Arcade physics then you want "collide" and "overlap"; you give them callbacks that are run when collisions and overlaps happen. Check out the arcade physics examples: http://phaser.io/examples/v2/arcade-physics/custom-sprite-vs-group Link to comment Share on other sites More sharing options...
Breno Pinheiro Posted April 6, 2016 Author Share Posted April 6, 2016 Yes, I know. But in this case, I would like that tile "disappears" of the screen. Using, for example, tile.sprite.kill() don´t work because the tile dont have a sprite attached with itself. Link to comment Share on other sites More sharing options...
WombatTurkey Posted April 6, 2016 Share Posted April 6, 2016 6 minutes ago, Breno Pinheiro said: Yes, I know. But in this case, I would like that tile "disappears" of the screen. Using, for example, tile.sprite.kill() don´t work because the tile dont have a sprite attached with itself. You can access all the tiles under the tilemap layer's children. They are each created as individual sprites (IIRC). (I'm still on Phaser 2.4.3) Everything is available to you, either by their group, or the group's .children property Link to comment Share on other sites More sharing options...
drhayes Posted April 7, 2016 Share Posted April 7, 2016 On 4/6/2016 at 11:07 AM, Breno Pinheiro said: Yes, I know. But in this case, I would like that tile "disappears" of the screen. Using, for example, tile.sprite.kill() don´t work because the tile dont have a sprite attached with itself. Ah, okay. That's not what you asked the first time. You're looking for "Phaser.Tilemap#removeTile", from wherever it is you're storing your tilemap. If it were named "tilemap", it'd be "tilemap.removeTile(tileX, tileY, layer);". Those two x and y are not the same as the sprite coordinates, they're the tile coordinates. The "layer" is whatever layer you want to remove the tile from. Link to comment Share on other sites More sharing options...
Breno Pinheiro Posted April 8, 2016 Author Share Posted April 8, 2016 thanks a lot, dr. hayes! Link to comment Share on other sites More sharing options...
Recommended Posts