Tilemap and gravity

39 views
Skip to first unread message

Petr Kavan

unread,
Aug 21, 2015, 5:21:23 PM8/21/15
to HaxeFlixel
I am trying to make a simple side-view platformer, with FlxTilemap as walls and FlxSprite as hero. In state update(). I'm calling FlxG.collide(this.walls, this.hero) so the walls really act as walls. Hero has gravity added with this.acceleration.y = 500; However, with gravity added, hero is no longer able to run on the ground.

See attached image - ground and air are clear, hero is the green box. In this situation, I cannot move him (with velocity.x) neither right nor left. I expect it is because if I try to move him right in a frame frame, hero moves a bit right and a bit down (due to gravity). He hits a floor tile to his bottom right, which stops his movement down, but to the right as well.

I think I am missing something simple there, but in this way it just doesnt work. Can somebody help me?
tilemap.jpg

Cam

unread,
Sep 5, 2015, 10:41:20 AM9/5/15
to HaxeFlixel
try using FlxG.overlap(player, level, null, FlxObject.separate);

hope this helps!
Reply all
Reply to author
Forward
0 new messages