Jump to content

Moving tileMapLayer does not work


KatsCyl
 Share

Recommended Posts

So, I've ran into a snag while trying to develop my game. The game has a quite a big world, to which tilemap based rooms are dynamically created to form a path through which the camera traverses through. In order to do this, I need to able to move entire tileMapLayers. However I simply cannot change the world position to which the tileMapLayer is rendered. The collisions showed by layer.debug = true; move just fine, the actual rendered layers are always in the world position (0, 0). I have set fixedToCamera false. Relevant code below:

http://pastebin.com/62RkrTPB

Thank you already for your help.

Link to comment
Share on other sites

The camera moves just fine. The problem is that I want to position the camera in the middle of the world, which is bigger than camera view, create a room, move it to camera view, create another room just outside camera view, and move the camera in the game world to create dungeon like levels.

Link to comment
Share on other sites

Oh! So you're saying that you've dynamically generated a level (as though in Tiled), add it to your game... and it's positioned right next to the center. You want to move it into position instead of leaving it where it is, right? I'm slow, but eventually I get there.

I don't know the answer to your question, so maybe we can change the question? I bet if each room is its own separate layer you're going to have problems after you add a few rooms. Might be better to call putTile on the tilemap (or fillTile) to dynamically generate different spaces?

Link to comment
Share on other sites

Hmmh, putTile seems a bit too rudimentary for my purposes. Each of my rooms have multiple layers, stairwells etc, so generating them dynamically would be a real bother. I don't currently dynamically generate rooms, just the level, which consist of about 5-10 rooms. Each of the rooms has its own tileMap also. I find it odd that even though in the tileMapLayer documentation it says that tileMapLayer.reset changes the worldPosition, it really doesn't do it. At least in my case. And also its odd, when I reset the room( = all of the layers in the room) to the desired position, that the collision boundaries move just fine, only the graphics are stuck at (0, 0).

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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