Jump to content

Tilemap + Phaser + Physics + Callbacks functions


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 post
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 post
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 post
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.

Guest
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.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...