Jump to content

Moving tilemap physics body position update (2.0)


HazA
 Share

Recommended Posts

Hi guys!

I am pretty new to phaser and html5 game development, but I am really amazed how fast the framework is moving forward and how kind and helpful the community is.
I found a forum thread for each problem I had so far ... until now ;)
 

So here is what I am trying to do ...

I create a world out of a tilemap and create a upper and lower layer ...
Now I want to move to lower layer down so the player moves down with the layer ...
But the problem is that the layer moves visually down, but the physics body stays where it was in the first place.

I created a gif showing exactly the problem..
I added physics debug drawings to better visualize the problem.

I am using the latest version 2.0 in Canvas mode.
The code is pretty much the code of some examples stiched together but I can post it of course if it's needed.
I hope you guys can help me.

Thanks

post-7612-0-25991300-1395098057.gif

Link to comment
Share on other sites

I'm afraid you can't move tilemaps yet, they are camera fixed and all collision is done against their coordinates, so although you've moved the tilemap sprite visually down, all of the collision data is still being processed from its original coordinates. It's on the roadmap to support moving tilemaps around and putting them next to each other for example, but in the meantime I'm afraid you'll need to try and do the above differently (ideally using a sprite instead).

Link to comment
Share on other sites

  • 1 year later...

I'm afraid you can't move tilemaps yet, they are camera fixed and all collision is done against their coordinates, so although you've moved the tilemap sprite visually down, all of the collision data is still being processed from its original coordinates. It's on the roadmap to support moving tilemaps around and putting them next to each other for example, but in the meantime I'm afraid you'll need to try and do the above differently (ideally using a sprite instead).

 

It is more than year ago, you answered here, is it still true that you cannot move tilemaps?

Link to comment
Share on other sites

  • 6 months later...
  • 2 months later...
  • 4 weeks later...
  • 1 year later...

Seems there's still no fix for this. Not sure why exactly. Haven't got a response on the issue yet, but been through the documentation and there's no method to move the tilemap body at all.

Should be possible manually, just haven't tried it yet. But, a quick fix workaround if you're using SHOW_ALL for fixed with display, is just to add extra space in the actual Tilemap file.

Theoretically, another 2 options to test are:

  1. Offset the physics bodies by the amount the tilemap layer is offset.
  2. Manually move the tilemap physics body
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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