Author Topic: [SOLVED] collision headache  (Read 1247 times)


  • Member
  • **
  • Posts: 87
  • Karma: +2/-0
    • View Profile
[SOLVED] collision headache
« on: Wed, Dec 28, 2011 »
alright code gurus, I wasn't sure which channel to post this in since this is regarding an XNA port of flixel, but I need help with it regardless.  I'm not using x-flixel, but instead I ported flixel over myself.  Everything thats essential works (sound, camera, tilemapping, zooming, state machine, etc) EXCEPT collision between tilemap and sprite, but sprite on sprite works just fine.

here's an image to demonstrate the problem:

the player goes through tiles from top and left, but collides from bottom and right.  when walking up/down a wall from the right, sprite walks smooth.  but when walking RIGHT TO LEFT only from the bottom, the sprite gets stuck at the corner of every tile.

I tried to keep the code identical to the originals. FlxObject, FlxQuadtree, FlxTilemap, FlxTile, all look the same. But some things were altered like uints to ints, members of FlxGroup are Lists<> not arrays. 

My server is down at the moment and I don't use github :( so I will have to give a megaupload link to the code.  I'll include the whole project which you can open in Visual Studio.  It's a Windows/XBOX project so it may ask for an xbox to be connected, but thats not a problem you can just right click on the project titled "Xbox360 Copy..." and click "Create Copy for Windows" and you can run it just fine.

I know I'm asking a lot, but it would be really awesome to have this issue finally figured out so that I can start making games on xbox :)
The project is zipped up, and only at ~700KB :)

I was using x-flixel but its a port of an outdated version flixel (remember when you had FlxG.follow(target, lerp), FlxG.followBounds(), etc), and its collision is not working correctly either.  even though the collision works much better than mine, it still isn't acting right because sprites get stuck at every tile, its impossible to walk smoothly along a floor or a wall.

my port is of the newest version, minus the multiple cameras.  and the only problem I have is the tile collision.  if anybody would be interested in helping me figure out the issues that would be really great and I would definitely share the code with everyone to use because the older version of flixel is just not as fun as the newer.

if figured out the issue. in FlxTilemap's overlapWithCallback function the range of tiles to be checked for collisions needed to be incremented by 2 instead of 1 and it solved the collision issue!

« Last Edit: Sat, Dec 31, 2011 by percevic »


  • Member
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: [SOLVED] collision headache
« Reply #1 on: Thu, Mar 15, 2012 »
I'm having this exact same issue. I'm doing my own port to XNA and when my sprite moves from right to left with gravity applied it gets stuck on every tile.  Increase the selection of tiles being checked doesn't help, and if I simply make to FlxObject blocks next to each other the same thing happens.