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

    witty-island-52596

    02/21/2023, 8:00 PM
    I don't know if you can see the contents of a remote folder and load each one
  • w

    witty-island-52596

    02/21/2023, 8:00 PM
    what are you trying to do?
  • k

    kind-restaurant-65061

    02/21/2023, 8:03 PM
    im creating a mmorpg where players can collect items and dress up chat etc. im going for desktop targets so what im trying to do is let the app load the items images from a remote server so that when i add new ones there wouldnt be a need to update the app
  • w

    witty-island-52596

    02/21/2023, 8:06 PM
    if it's an MMOrpg you'll probably be recompiling/releasing it frequently anyway
  • w

    witty-island-52596

    02/21/2023, 8:07 PM
    but rather than having your client search a remote directory for corresponding files the server should have some api that lets you request a list of file urls pertaining to some category
  • m

    mammoth-plastic-35593

    02/21/2023, 8:45 PM
    How careful / consistent are any of you with properly `put()`'ing the FlxPoints, FlxRects, etc? I've noticed there are some inconsistency in the flixel code such as in
    FlxBitmapFont
    where it is just set to null instead of being
    put
    into the pool (https://github.com/HaxeFlixel/flixel/blob/dev/flixel/graphics/frames/FlxBitmapFont.hx#L99) Is that intentional? I'm basically doing a cleanup pass in my code base and noticing some of that in various flixel classes.
  • k

    kind-restaurant-65061

    02/21/2023, 8:48 PM
    thanks, one more thing tho im creating a game like cube crush. when adding my cubes the fps drops. is there any way i can optimize this
  • k

    kind-restaurant-65061

    02/21/2023, 8:48 PM
  • k

    kind-restaurant-65061

    02/21/2023, 8:49 PM
  • h

    hallowed-holiday-15370

    02/21/2023, 8:51 PM
    I'm not going to try to read that code - try pasting in the code tags... But, off the top of my head - you are always going to have at most
    Width * height
    squares in your game? don't add new ones - just make the max you'll ever need,
    kill
    them, and
    revive
    them as needed
  • k

    kind-restaurant-65061

    02/21/2023, 8:53 PM
    so i have 3 cubes that add randomly in a tile map consisting of 15 rows and columns so ill need 225 cubes how can i achieve this
  • w

    witty-island-52596

    02/21/2023, 9:46 PM
    use code tags, like SeiferTim said, like this \`\`\`hx // code here \`\`\`
  • k

    kind-restaurant-65061

    02/21/2023, 11:16 PM
    Copy code
    hx
    package;
    
    import flixel.FlxSprite;
    import flixel.system.FlxAssets.FlxGraphicAsset;
    
    
    class Tile extends FlxSprite
    {
        public var type:Int;
        public var col:Int;
        public var row:Int;
        
        
        public function new(?X:Float = 0, ?Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset, r:Int, c:Int, t:Int){
            super(X, Y, SimpleGraphic);
            
            row = r;
            col = c;
            type = t;
        }
        
        override public function update(elapsed:Float){
            super.update(elapsed);
        }
        
    }
  • k

    kind-restaurant-65061

    02/21/2023, 11:17 PM
    Copy code
    hx
    package;
    
    import flixel.FlxState;
    import flixel.FlxSprite;
    import flixel.FlxG;
    import flixel.math.FlxRandom;
    import flixel.group.FlxSpriteGroup;
    
    
    class PlayState extends FlxState
    {
        
        var tile:Tile;
        var bg:FlxSprite;
        var tilesMatrix:Array<Array<Tile>>; 
        
        var COLS:Int = 15;
        var ROWS:Int = 15;
        
        var xInit:Float;
        var yInit:Float;
        
        var z:FlxRandom;
        var r:Int;
        var w = 25;
        var h = 25;
        
        var mRow:Int;
        var mCol:Int;
        var matrix:Array<Array<Int>>;
        
        override public function create()
        {
            super.create();
            
            z = new FlxRandom();    
            yInit = FlxG.height/2-(h+1)*ROWS/2;
            xInit = FlxG.width/2-(w+1)*COLS/2;
            matrix = new Array();
            
            tilesMatrix = new Array();
            
            for(col in 0...COLS){
                matrix[col] = new Array();
                tilesMatrix[col] = new Array();
                for(row in 0...ROWS){
                    
                    r = z.int(0, 2);
                    
                    if(r == 0){
                        tile = new Tile(xInit+(w+1)*col, yInit+(h+1)*row, "assets/images/yellow.png", row, col, 0);
                        add(tile);
                        matrix[col][row] = 0;
                        tilesMatrix[col][row] = tile;
                    } else if(r == 1){
                        tile = new Tile(xInit+(w+1)*col, yInit+(h+1)*row, "assets/images/red.png", row, col, 1);
                        add(tile);
                        matrix[col][row] = 1;    
                        tilesMatrix[col][row] = tile;
                    } else {
                        tile = new Tile(xInit+(w+1)*col, yInit+(h+1)*row, "assets/images/blue.png", row, col, 2);
                        add(tile);    
                        matrix[col][row] = 2;
                        tilesMatrix[col][row] = tile;    
                    }
                }
            }
        }
    
    
    }
  • k

    kind-restaurant-65061

    02/21/2023, 11:22 PM
    my cubes are 25 x 25 pixels each
  • w

    witty-island-52596

    02/22/2023, 1:01 AM
    https://snippets.haxeflixel.com/groups/recycling/ Flx groups allow you to recycle members that have been killed
  • w

    witty-island-52596

    02/22/2023, 1:01 AM
    You should be using FlxTypedGroups instead of arrays to begin with
  • s

    square-angle-35096

    02/22/2023, 1:05 AM
    maybe this is more of an openfl question but is there how to apply like an alpha value to an entire spritesheet instead of to specific objects?
  • s

    square-angle-35096

    02/22/2023, 1:05 AM
    code-wise
  • w

    witty-island-52596

    02/22/2023, 1:06 AM
    Like you want to set the alpha for all sprites using a certain image without setting them all individually?
  • s

    square-angle-35096

    02/22/2023, 1:06 AM
    uh huh
  • w

    witty-island-52596

    02/22/2023, 1:07 AM
    You can edit the bitmapData of the graphic they are using. But i think i would just put them all in a group and set their alpha iteratively
  • w

    witty-island-52596

    02/22/2023, 1:08 AM
    Changing bitmap data is costly and hard to undo
  • s

    square-angle-35096

    02/22/2023, 1:08 AM
    mhm
  • s

    square-angle-35096

    02/22/2023, 1:08 AM
    i guess i'll just edit the image then thats probably better
  • w

    witty-island-52596

    02/22/2023, 1:08 AM
    I doubt it
  • w

    witty-island-52596

    02/22/2023, 1:09 AM
    Could also put them all in a sprite group and set the sprite groups alpha
  • s

    square-angle-35096

    02/22/2023, 1:09 AM
    yeye
  • s

    square-angle-35096

    02/22/2023, 1:09 AM
    but thank you anyways
  • h

    hallowed-ocean-84954

    02/22/2023, 4:48 AM
    Just hit a case I often hit - not flixel - openfl HaxeUI. Changed the UI yesterday - still builds with the old wrong UI layout from vscode. Build from powershell with
    lime test hl -debug
    and it's fine. Go back to vscode and build and it's still wrong. I hit this with HaxeUI intermittently - still haven't found the cache - usually just blowing away Exports/hl is enough but that doesn't explain how powershell is getting clean builds. Unless that cleans the relevant cached bits too. Actually just clean the export and it still built incorrectly so that ain't it.
1...946594669467...9809Latest