howto apply useScaleHack on FlxSprites?



  • Hi all,

    I'm writing a game in Haxeflixel. The game is a big FlxTilemap. Most tiles can be picked-up. I use: setTileByIndex to empty out tiles where the character has walked. If I don't use the: useScaleHack on the FlxTilemap then there is a tear-off. So i'm forced to use it.

    Now, some tiles are not collectible and will have a (custom made) physics functionality (rocks that drop to the ground). I don't want to use FlxSprite on all rocks on the map because this causes performance issues. (The FlxTilemap renders nice, but filling the map with lots of FlxSprites is heavy-duty) Instead I just want to swap the tile that needs to fall with a FlxSprite and swap it back again to a tile when the physics ends.

    useScaleHack scales the tiles, so if I swap the tile with a FlxSprite (of the same picture) it renders different. If I don't use: useScaleHack this does not happen and the FlxSprite and Tile are the same when swapping... But then we have a tear-off :(

    So i'm wondering if i can apply the useScaleHack filter on FlxSprite somehow? Or is there any other trick for swapping the tile to a FlxSprite without having a graphical difference? Or maybe just use a different approach that I did not think off yet?

    Many thanks in advanced for any help you might have!

    Greetz!


  • administrators

    It's recommended to use this approach instead of useScaleHack:

    http://forum.haxeflixel.com/topic/39/tilemap-tearing-desktop-targets/2



  • @Gama11 :: Thanks for your reply! Using the approach from your link solved the tear-off problems hence not needing useScaleHack anymore. Now the graphics on both the tiles and the FlxSprites are the same and with that my problem is solved!

    * As a quick reference. This is what i'm using now to make the tilemap:

    /////
    var _tmap:FlxTilemap = new FlxTilemap();
    var tile_w:Int = 100;
    var tile_h:Int = 100;
    var g = FlxTileFrames.fromBitmapAddSpacesAndBorders(AssetPaths.mytilemap__png, new FlxPoint(tile_w, tile_h), new FlxPoint(0,0), new FlxPoint(2,2));
    _tmap.loadMapFromArray(/* array */, /* array_width */, /* array_height */, g, tile_w, tile_h);
    _tmap.useScaleHack = false;
    /////

    Thanks a lot!

    (* Edit a typo :)


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.