Getting property fields from a Tiled map



  • Hi everyone

    I'm new to the forums and pretty new to Haxe (and Haxeflixel) as well.

    I'm using a Tiledmap to create a level in my game, and when I try to get the flippedVertically property, I'm getting a TInt value. That's the good part : there seems to be a different value if the object is flipped or not, but it's not true or false and I can't use it as such.

    	for (enemy in getLevelObjects(tiledMap, "enemies"))
    		{		
    				var flipped:Bool = cast(enemy.flippedVertically, Bool);
    				trace(Type.typeof(flipped));
                      }
    

    Trace gives me "TInt" in this example. Trying to get the value of flipped always gives me false though. The same happens if I try to get the value after the object is created and try to gather those values from the PlayState.

    The only solution that I have found is very silly, but it's casting Int on that value and using it to compare if it's either equal or bigger than 0... which works, but I want to be able to use a boolean and do this properly.

    Anyone got any idea what is going on here? I've been trying to solve this for a couple of days now, and even with the help of some other users we couldn't find a solution.

    Thanks!


  • administrators

    What's enemy? A TiledObject? The flippedVertically property there is a Bool already: http://api.haxeflixel.com/flixel/addons/editors/tiled/TiledObject.html?#flippedVertically



  • He said that somehow he get an Int instead?



  • @Gama11 said in Getting property fields from a Tiled map:

    What's enemy? A TiledObject? The flippedVertically property there is a Bool already: http://api.haxeflixel.com/flixel/addons/editors/tiled/TiledObject.html?#flippedVertically

    It is a TiledObject, but it returns a Tint. With the help from Foxel and Dlean Jeans on the Discord chat group, we managed to find a workaround, but the fact is that flippedVertically does not return a Bool, at least not in my case.

    Maybe Foxel could chime in, as I'm very new to all this.


  • administrators

    Were you not able to use it as a Bool / got compiler errors?

    Type.typeof() returns the type of a variable at runtime, but that's not necessarily relevant. What target was this on?



  • @Gama11 said in Getting property fields from a Tiled map:

    Were you not able to use it as a Bool / got compiler errors?

    Type.typeof() returns the type of a variable at runtime, but that's not necessarily relevant. What target was this on?

    Target was Neko, and yeah, trying to get a Bool from the TInt value always returned false, even though the values were different (0 and 1073741824).

    cast(enemy.flippedVertically, Bool); throws as Class cast error. Is that intended? Or maybe I'm using it incorrectly...


  • administrators

    This is actually a bug in TiledObject. I pushed a fix to the dev branch:

    https://github.com/HaxeFlixel/flixel-addons/commit/fbdc71c151de27d78c1045bd02a123d566a631b8



  • Perfect, thanks for taking a look and for the help!


Log in to reply