Jump to content

Tilemap + Phaser + Physics + Callbacks functions


Breno Pinheiro
 Share

Recommended Posts

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

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

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

 Share

  • Recently Browsing   0 members

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