Moving tilemaps

  • I am experimenting with the FlxCollisions demo to see how well HaxeFlixel handles moving tilemaps (I am thinking of a game where the level is in several independently-moving sections, so I do want the flexibility of having tilemaps which move relative to one another). Setting .moves on a tilemap and assigning a path to it seems to do most of what I want, but the player object 'stutters' while it's on a tile which is moving up or down and so can't move properly. The same demo already has a vertically-moving platform in it which handles fine, so I know this should be possible in theory. I also modified FlxTilemap.overlapsWithCallback to assign tile.velocity = velocity before calling the callback which seems to have improved but not fixed the behaviour. Demo below:

    Any thoughts gratefully appreciated!

  • You mean at the top of the elevator? One possibilty is giving player velocity.y the same as elevator's

  • That's not the part I meant - the problem is that when the player is standing on a tile which is moving upwards, it's impossible to move left and right (I think the player must be continually colliding with the floor in some way). Standing on the platform which is a single large FlxSprite, it's possible to move left and right as normal.

  • I think I've figured it out - tilemap collisions are handled by colliding the object separately against each relevant tile in the tilemap. Unfortunately flixel does collision separation on the x axis before the y axis, so the player object is pushed horizontally rather than vertically off the top corner of the rising floor tile.

    No idea how to fix this without rewriting the entire flixel physics system though ...

  • Collide() function is overlap() with separate() as argument. Your can rewrite separate() and pass it to overlap().

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.