Author Topic: v1.25 - Incorrect tilemap collision handling (wraparounds) [Fix]  (Read 1494 times)

nitram_cero (2bam)

  • Contributor
  • ****
  • Posts: 484
  • Karma: +0/-0
    • View Profile
    • 2BAM
Hi, I found that these lines are incorrect (@ FlxTilemap.as):

Code: [Select]
for(var r:uint = 0; r < ih; r++)
{
if((r < 0) || (r >= heightInTiles)) continue;
for(c = 0; c < iw; c++)
{
if((c < 0) || (c >= widthInTiles)) continue;

Because r and c are offsets. The real check should be made like this to avoid overlaps (If you have differently sized layers and collide to both, it could lead to some strange blocking in plain "empty" cells.

The Fix
Code: [Select]
for(var r:uint = 0; r < ih; r++)
{
if((r+iy < 0) || (r+iy >= heightInTiles)) continue;
for(c = 0; c < iw; c++)
{
if((c+ix < 0) || (c+ix >= widthInTiles)) continue;

Regards

« Last Edit: Fri, Oct 23, 2009 by nitram_cero »