Closed bguiz closed 9 years ago
Are you on dev flixel? How are you loading in the map data (ie which method)?
@MSGhero Nope I'm not on dev flixel, where is that?
Here's what I do in PlayState.hx:
override public function create():Void
{
tileMap = new FlxTilemap();
var mapCsv = Assets .getText("assets/data/map.csv");
tileMap.loadMap(mapCsv, "assets/images/tileset.png", TILE_WIDTH, TILE_HEIGHT, 0, 1);
add(tileMap);
http://haxeflixel.com/documentation/install-development-flixel/
The loadMap function has been replaced with other ones, so idk if they would fix this now. There's lots of other breaking changes from master to dev, so watch for the errors.
@bguiz Can you provide the necessary assets to compile that code snippet? Also, where's your pathfinding code? computePathDistance()
wouldn't be called without a findPath()
call.
Does the Pathfinding demo run fine?
@msghero thanks for that. What has FlxTilemap#loadMap been replaced with though?
Also, I think I would prefer to compile against released versions of libraries.. As it is, I'm having trouble with API differences from one version to the next preventing openfl-bitfive from compiling it, this using the bleeding edge is likely to just exacerbate this.
@gama11 Ok thanks, I'll find the path finding demo and attempt to reproduce this.
@gama11 Just got a chance to try this out. Unfortunately, the path finding demo does not work. It fails in a different function - findPath
instead of computePathDistance
- but the error does look like it most likely shares a common cause, which is that either _tileObjects
or _data
is incorrectly populated at the time that findPath
function is called:
flixel.tile.FlxTilemap.prototype = $extend(flixel.FlxObject.prototype,{
...
,findPath: function(Start,End,Simplify,RaySimplify,WideDiagonal) {
...
if(this._tileObjects[this._data[startIndex]].allowCollisions > 0 || this._tileObjects[this._data[endIndex]].allowCollisions > 0) return null;
Results in an error: Uncaught TypeError: Cannot read property 'allowCollisions' of undefined
In the pathfinding demo app,
$ /usr/lib/haxe/lib/flixel-demos/1,1,1/Flixel Features/Pathfinding
$ lime test html5
# in the browser, click on "Move to Goal" button immediately, without doing anything else
this resulted in an error because
startIndex
was 0, and endIndex
was 649this_data
was an array which has a length of 650, therefore the indices represented by startIndex
and endIndex
were indeed validUnfortunately, however, the last 25 positions in the this._data
array were null
, as shown by inspecting the debug output like so:
$ this._data.map(function(datum, idx) { return (typeof datum !== 'number') ? idx : null; }).filter(function(datum) { return (typeof datum === 'number'); }); $ [625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649]
FlxTilemap
has a width of 25 tiles, meaning that the last row of tiles has gone missingThis might be the root cause of it, but I am not able to say for sure.
Nudge, nudge On 28 Nov 2014 22:41, "Gama11" notifications@github.com wrote:
@bguiz https://github.com/bguiz Can you provide the necessary assets to compile that code snippet? Also, where's your pathfinding code? computePathDistance() wouldn't be called without a findPath() call.
Does the Pathfinding demo run fine?
— Reply to this email directly or view it on GitHub https://github.com/HaxeFlixel/flixel/issues/1390#issuecomment-64885429.
Can't reproduce this issue in the Pathfinding demo anymore on latest dev. There've been fixes here and there, so I assume this is not an issue anymore.
The class
flixel.tile.FlxTilemap
has a methodcomputePathDistance
. When compiled with the neko or flash targets, this compiles and runs without issue. When compiled using openfl-bitfive with the html5 target, however, this compiles, but does not run.The relevant parts of the transpiled Javascript code:
An error occurs on the line before the
i++
, becausethis._tileObjects[this._data[i]]
is sometimesundefined
:@YellowAfterlife the maintainer of openfl-bitfive thinks that this issue has to do with haxeflixel, not openfl-bitfive: https://github.com/YellowAfterlife/openfl-bitfive/issues/31#issuecomment-64843735
After comparing the original Haxe source and the transpiled Javascript output, it does look as if the error surfaces here, but most likely occurs earlier on, elsewhere. The likely culprits are when
_tileObjects
(Array<FlxTile>
) or_data
(Array<Int>
) are populated. However, that is about as deep as I know how to dig.Can someone smarter than I please take a look and see if there is something going amiss here?