https://linen.dev logo
Join Discord
Powered by
# flixel
  • s

    square-angle-35096

    02/21/2023, 3:34 PM
    the GC automatically runs in any haxe program.
  • s

    square-angle-35096

    02/21/2023, 3:34 PM
    that includes flixel projects
  • m

    most-eve-98431

    02/21/2023, 3:34 PM
    Oohh
  • s

    square-angle-35096

    02/21/2023, 3:34 PM
    (GC = Garbage Collector)
  • s

    square-angle-35096

    02/21/2023, 3:35 PM
    you can mess up with it if you want but its not recommended
  • s

    square-angle-35096

    02/21/2023, 3:35 PM
    with stuff such as entering in gc free zones
  • l

    lively-computer-90469

    02/21/2023, 4:03 PM
    the only thing i wanna know is if we can influence the garbage collector like java
  • l

    lively-computer-90469

    02/21/2023, 4:03 PM
    like encourage it to pick up anything we missed
  • h

    hallowed-ocean-84954

    02/21/2023, 4:04 PM
    It'll be target specific as all the gc's are in the targets
  • l

    lively-computer-90469

    02/21/2023, 4:05 PM
    that makes sense
  • s

    square-angle-35096

    02/21/2023, 4:13 PM
    but yea you can force the GC to run again
  • s

    square-angle-35096

    02/21/2023, 4:14 PM
    just do something like
    Copy code
    hx
    #if cpp
    import cpp.vm.Gc;
    #elseif hl
    import hl.Gc;
    #elseif java
    import java.vm.Gc;
    #elseif neko
    import neko.vm.Gc;
    #end
  • s

    square-angle-35096

    02/21/2023, 4:17 PM
    and then like do these for each target
    Copy code
    hx
    //java neko and cpp clear minor
    Gc.run(false);
    
    //cpp clear major
    Gc.run(true);
    Gc.compact();
    
    //Hashlink clear major
    Gc.major();
    
    //Java and neko clear major
    Gc.run(true);
  • p

    purple-toddler-22641

    02/21/2023, 5:11 PM
    Why is a
    final
    FlxColor not considered constant? 🤔
  • p

    purple-toddler-22641

    02/21/2023, 5:12 PM
    When I try something like
    function new(Color:FlxColor = MyColor){}
    it complains that
    Parameter default value should be constant
    even when I define
    MyColor
    as
    final
  • w

    witty-island-52596

    02/21/2023, 5:38 PM
    constant means defined at compile time, i thought
  • w

    witty-island-52596

    02/21/2023, 5:40 PM
    finals can be defined at runtime
  • w

    witty-island-52596

    02/21/2023, 5:40 PM
    might want to use ?Color:FlxColor and set it to MyColor, if null, since that's effectively what it's doing
  • Dealing with multiple sizes of the same images
    h

    hallowed-holiday-15370

    02/21/2023, 5:42 PM
    What is the ideal/recommended way to deal with having alternate sizes of the same images ? Typically when I work on a game, I need to make my assets at a single size and that's it. Done. For this game I'm working on, I have a LOT of icons that get shown in different places and need to be different sizes. For example: on the main game screen they are 128x128, but in Tooltips, they need to be 24x24, in the HUD they are 36x36, and in a few other places I am using the 128x128 version because the 36x36 looks too small and I think I'm going to want to get a new size (64x64?) for those... Currently, I'm grabbing all of these sprites from https://game-icons.net/ and there are 48 of them in the game right now. I'm downloading them as PNG in the 4 different sizes I need (128, 36, 24) into different folders, and then I have a command line script that passes them all to ShoeBox to generate 3 different sprite sheets (one for each size) If I want to add a new icon, I have to download it 3 times and run my script... if I decide (like I am now) that I want another size, well I have to download each image 1-by-1 3 times. Instinctively, this is triggering my common sense alarm which says: "Surely this is not how any one else does this!" But I don't know what the "right" way is! I have tried just downloading the larger version of the sprite and scaling them in Photoshop, but they don't look as good. I have also tried grabbing the SVG version to convert to the 3 pngs - they look better, but I can't automate this very well... I have not tried just having the large version in-game and having logic to scale them when I need them - I feel like scaling them whenever I display them is going to lead to performance issues - esp when I have a LOT on the screen at once... ALSO, I'm doing something hacky with the 24 and 36 size sprites and appending them to my BitmapFonts so I can use them as glyphs inside FlxBitmapTexts and I think scaling those would not work...
    w
    • 2
    • 43
  • p

    purple-toddler-22641

    02/21/2023, 6:01 PM
    Yeah that's what I'm doing
  • p

    purple-toddler-22641

    02/21/2023, 6:01 PM
    Was just wondering since I thought final would be final enough
  • w

    witty-island-52596

    02/21/2023, 6:13 PM
    it's not that it's not final enough, it's plenty final
  • w

    witty-island-52596

    02/21/2023, 6:13 PM
    it's just not constant
  • k

    kind-restaurant-65061

    02/21/2023, 7:40 PM
    hi guys, is it possible to load your assets from a remote server dynamically?
  • w

    witty-island-52596

    02/21/2023, 7:43 PM
    there are ways to load external files, but they won't be accessible the way packaged assets are
  • w

    witty-island-52596

    02/21/2023, 7:45 PM
    you can load a bitmapData from a remote url, and pass that bitmapData into a sprite.loadGraphic(): https://api.openfl.org/openfl/display/BitmapData.html#loadFromFile FlxSound.loadStream can take a remote url as well, https://api.haxeflixel.com/flixel/system/FlxSound.html#loadStream
  • w

    witty-island-52596

    02/21/2023, 7:46 PM
    and there's haxe methods to load any file, like json
  • w

    witty-island-52596

    02/21/2023, 7:47 PM
    wait, use BitmapData.loadFromFile, not fromFile
  • k

    kind-restaurant-65061

    02/21/2023, 7:51 PM
    will the app automatically load everything that’s contained within the folder even when i add new images?
  • w

    witty-island-52596

    02/21/2023, 7:59 PM
    the remote folder?
1...946494659466...9809Latest