AS3 tile discontinuity after panning
I'm breaking info out of the thread I started writing it in, on account of it taking over that otherwise dead thread.
Originally, "I've had some issues with tiles not being flush after recentering (either via double click or API calls, AS3 codebase)."
Basically, tiles aren't being positioned to round numbers, and the Flash engine deals with this poorly, creating gaps between tiles.
Note that TileGrid's NormalizeWell method appears to realize this can be an issue, but this only fires after zooms, not after pans. Calling it after a pan has it own set of issues (circular loops, and also as below).
Rounding TileGrid.as's centerWell method's adjustTiles deltas fixes this, but breaks other stuff. Notably, panning gets rounding into multiples of map.as's "panFrames" (by default, 12).
Want to pan 5 pixels? You'll pan Math.round(5/12)*12 = 0 pixels.
Want to pan 6 pixels? You'll pan Math.round(6/12)*12 = 12 pixels.
I think I have a pretty decent fix for all this. I've overrided the x and y properties to Tile.as, keeping track of unrounded position, but also setting the real x/y's to rounded values.
Things looks pretty decent with this fix. Here is the meat of it:
protected var __x:Number;
protected var __y:Number;
public override function get x():Number
{
return this.__x;
}
public override function set x(_lx:Number):void
{
this.__x = _lx;
super.x = Math.floor(_lx);
}
public override function get y():Number
{
return this.__y;
}
public override function set y(_ly:Number):void
{
this.__y = _ly;
super.y = Math.floor(_ly);
}
Originally, "I've had some issues with tiles not being flush after recentering (either via double click or API calls, AS3 codebase)."
Basically, tiles aren't being positioned to round numbers, and the Flash engine deals with this poorly, creating gaps between tiles.
Note that TileGrid's NormalizeWell method appears to realize this can be an issue, but this only fires after zooms, not after pans. Calling it after a pan has it own set of issues (circular loops, and also as below).
Rounding TileGrid.as's centerWell method's adjustTiles deltas fixes this, but breaks other stuff. Notably, panning gets rounding into multiples of map.as's "panFrames" (by default, 12).
Want to pan 5 pixels? You'll pan Math.round(5/12)*12 = 0 pixels.
Want to pan 6 pixels? You'll pan Math.round(6/12)*12 = 12 pixels.
I think I have a pretty decent fix for all this. I've overrided the x and y properties to Tile.as, keeping track of unrounded position, but also setting the real x/y's to rounded values.
Things looks pretty decent with this fix. Here is the meat of it:
protected var __x:Number;
protected var __y:Number;
public override function get x():Number
{
return this.__x;
}
public override function set x(_lx:Number):void
{
this.__x = _lx;
super.x = Math.floor(_lx);
}
public override function get y():Number
{
return this.__y;
}
public override function set y(_ly:Number):void
{
this.__y = _ly;
super.y = Math.floor(_ly);
}
1
person has this problem
I have this problem, too!
Tell me when someone solves it.
The more people who report this problem, the more it gets noticed.
The more people who report this problem, the more it gets noticed.
-
Inappropriate?Hi Bill,
Thanks for this (and the associated email). I'm testing it now.
Tom.
I’m excited
Loading Profile...






EMPLOYEE

