Skip to first unread message

Raul Rivera Arroyo

unread,
Jul 5, 2015, 10:01:00 PM7/5/15
to haxef...@googlegroups.com
Hello again fellow coders. I've been having some issues with this class while I follow along this tutorial : http://haxeflixel.com/documentation/part-viii-enemies-and-basic-ai/. I've spent a good amount of time between yesterday and today trying to get to the bottom of it, but I fear that my little knowledge of Haxe, although increasing, limits me somewhat. Thankfully, I've a workaround in place that suits me well. But if I want to know how to use this class correctly, I need to know what's wrong with my code. Or if it's perhaps not my code but Ogmo Editor trolling me somehow. First, here is my issue, a stacktrace:

Invalid field access : allowCollisions
Called from flixel/tile/FlxTilemap.hx line 1357
Called from PlayState.hx line 115
Called from flixel/group/FlxTypedGroup.hx line 651
Called from PlayState.hx line 92
Called from flixel/FlxState.hx line 155
Called from flixel/FlxGame.hx line 700
Called from flixel/FlxGame.hx line 648
Called from flixel/FlxGame.hx line 493
Called from openfl/_legacy/events/EventDispatcher.hx line 98
Called from openfl/_legacy/display/DisplayObject.hx line 182
Called from openfl/_legacy/display/DisplayObject.hx line 161
Called from openfl/_legacy/display/DisplayObjectContainer.hx line 280
Called from openfl/_legacy/display/Stage.hx line 1098
Called from openfl/_legacy/display/Stage.hx line 351
Called from openfl/_legacy/display/Stage.hx line 1079
Called from openfl/_legacy/display/Stage.hx line 430

Playstate.hx line 115 is:

if (_mWalls.ray(e.getMidpoint(), _player.getMidpoint()))

Playstate.hx line 92 is:

_grpEnemies.forEachAlive(checkEnemyVision);

The context of what's happening is, once I test the project out it either A) Crashes immediately, or B) Crashes just a few seconds in. If I eliminate a few enemy entities from the level using Ogmo, and just place one entity, the project does not crash immediately. Im able to move around, if the enemy has line of sight, he will head towards me. If I escape, he stops following and just goes back to moping around. After a while though, the game crashes again and gives me that invalid field access. Im not sure if the checkEnemyVision function is crashing my game as the raycast hits a wall, if its Ogmo and it's entities or if it's something else. I've attached my playstate.hx code. Followed along the tutorial.
PlayState.hx

Brian Flyte

unread,
Jul 6, 2015, 10:07:49 PM7/6/15
to haxef...@googlegroups.com
I don't see anything wrong with the PlayState. Maybe it's something in the Enemy class?

Jimmy JimJim

unread,
Jul 6, 2015, 10:14:40 PM7/6/15
to haxef...@googlegroups.com
Invalid field access means it tried to access a property which does not exist. Throw some breakpoints in at line 115 and see if perhaps the raycast is firing before HaxeFlixel has properly setup all the entities. 

Bl4ckb0ne

unread,
Jul 7, 2015, 1:40:35 AM7/7/15
to haxef...@googlegroups.com
Check if the field you're trying to acces is not out of bounds or null.

Junjo

unread,
Jul 8, 2015, 3:05:33 AM7/8/15
to haxef...@googlegroups.com
Given that the error is thrown from FlxTilemap.hx, I would check if you are using a correct version set of the libraries.

Raul Rivera Arroyo

unread,
Jul 9, 2015, 7:01:48 PM7/9/15
to haxef...@googlegroups.com
Hey guys, thanks for the comments. I was able to fix the problem with some help from the IRC chat channel. The problem I was having is that OGMO was setting some tilemap values to -1 in the .oel file. This is what was causing the ruckus. However, adding:

var tiles = _mWalls.getData(); for (i in 0...tiles.length) if (tiles[i] < 0) tiles[i] = 0;

to the create() function in the PlayState resolved the issue, though the .oel file still has the values outside of the map as -1.
Reply all
Reply to author
Forward
0 new messages