https://linen.dev logo
Join Discord
Powered by
# openfl
  • b

    bright-restaurant-79188

    01/25/2023, 12:37 AM
    https://tenor.com/view/parks-and-recreation-tv-show-ron-swanson-nick-offerman-throwing-away-computer-gif-17541708
  • b

    bright-restaurant-79188

    01/25/2023, 12:38 AM
    I was so close to this lol
  • a

    able-action-74275

    01/25/2023, 12:40 AM
    haha
  • a

    able-action-74275

    01/25/2023, 12:40 AM
    no problem
  • a

    able-action-74275

    01/25/2023, 12:40 AM
    you could probably edit the source so that all images are set to
    smooth = false
    by default
  • a

    able-action-74275

    01/25/2023, 12:41 AM
    hacky but ...
  • a

    able-action-74275

    01/25/2023, 12:41 AM
    maybe make an issue on haxepunk repo, not sure how active it is though
  • a

    able-action-74275

    01/25/2023, 12:42 AM
    it's crazy how hard it is to get pixelated images sometimes lol
  • a

    able-action-74275

    01/25/2023, 12:43 AM
    not used it myself but in unity I think you need a specific camera or something
  • b

    bright-restaurant-79188

    01/25/2023, 12:47 AM
    i know, you'd think something like that would be very simple to do
  • a

    able-action-74275

    01/25/2023, 12:47 AM
    totally
  • b

    bright-restaurant-79188

    01/25/2023, 12:48 AM
    also, it looks like using
    Copy code
    img.smooth = false
    might actually be the intended way to do pixelated scaling in HaxePunk
  • b

    bright-restaurant-79188

    01/25/2023, 12:48 AM
    I found this in the screenscale example in the HaxePunk git repo:
  • b

    bright-restaurant-79188

    01/25/2023, 12:48 AM
    Copy code
    override public function begin()
        {
            var tilemap = new Tilemap("graphics/tiles.png", 840, 512, 60, 60, 4, 4);
            for (x in 0 ... Std.int(840/60))
            {
                for (y in 0 ... Std.int(480/60))
                {
                    tilemap.setTile(x, y, Std.random(4));
                }
            }
            tilemap.smooth = false;
            // make any seams caused by scaling obvious
            tilemap.scale = 1.1;
            addGraphic(tilemap);
    
            label = new Text("Default\nClick to change scale mode.");
            label.smooth = false;
            addGraphic(label);
            label.y = HXP.height/2;
    
            setScaleMode();
        }
  • b

    bright-restaurant-79188

    01/25/2023, 12:48 AM
    taken from MainScene.hx
  • b

    bright-restaurant-79188

    01/25/2023, 12:49 AM
    when this application runs the background isn't pixelated, regardless of window size
  • b

    bright-restaurant-79188

    01/25/2023, 12:49 AM
    so I guess this is just how we're supposed to it if this is how the official example does it 🤷‍♂️
  • a

    able-action-74275

    01/25/2023, 12:49 AM
    yeah guess so
  • b

    bright-restaurant-79188

    01/25/2023, 12:55 AM
    well, I guess that's case closed
  • b

    bright-restaurant-79188

    01/25/2023, 12:56 AM
    https://tenor.com/view/there-you-have-it-boys-case-closed-the-simpsons-gif-13616870
  • b

    bright-restaurant-79188

    01/25/2023, 12:56 AM
    thanks again :)
  • p

    powerful-morning-89

    01/25/2023, 7:12 AM
    @able-action-74275 @bright-restaurant-79188 Just FYI: the
    smooth
    property doesn't seem to have anything to do with anti-aliasing, what it actually controls is linear vs point sampling. (minification filtering seems to be always linear, but smooth = true will make it use linear filtering for magnification too.) (But in the screenshots half shared it seems to be doing the opposite... maybe the smooth property is inverted somewhere?)
  • e

    elegant-cat-63914

    01/25/2023, 6:57 PM
    does anyone know why
    Assets.loadBitmapData
    doesn't work on the first try when using
    Future<T>.result()
    , but succeeds any try after that?
  • a

    able-action-74275

    01/25/2023, 7:05 PM
    can you post an example of how you use it?
  • e

    elegant-cat-63914

    01/25/2023, 7:06 PM
    this
    Copy code
    var loadingBitmap:Future<BitmapData> = OpenFlAssets.loadBitmapData(path).onError(loadingError);
    var newBitmap:BitmapData = loadingBitmap.result();
    
    var newGraphic:FlxGraphic;
    
    if (newBitmap == null)
        return FlxG.bitmap.add("flixel/images/logo/default.png"); //get the flixel default image to prevent crashes
                   
    newGraphic = FlxGraphic.fromBitmapData(newBitmap, false, path);
    newGraphic.persist = true;
  • a

    able-action-74275

    01/25/2023, 7:19 PM
    you need to use it like this
    Copy code
    hx
    var future = Assets.loadBitmapData(path);
    
    uture.onError(error -> {
        // handle error if there was one
    });
    
    future.onComplete(asset ->
    {
        // handle asset now it is loaded
        newGraphic = FlxGraphic.fromBitmapData(asset)
    });
  • a

    able-action-74275

    01/25/2023, 7:19 PM
    or similar
  • a

    able-action-74275

    01/25/2023, 7:20 PM
    in your code
    loadingBitmap.result();
    is probably null the first time because it didn't finish loading by using the onComplete event it will have finished loading
  • a

    able-action-74275

    01/25/2023, 7:20 PM
    though I wonder if you need to use this at all
  • e

    elegant-twilight-61392

    01/25/2023, 7:21 PM
    if they are loading an arbitrary resource in the browser, it must be async
1...373839...57Latest