https://linen.dev logo
Join Discord
Powered by
# ceramic
  • g

    gifted-whale-78169

    08/10/2022, 12:00 AM
    thats what i was thinking about doing
  • g

    gifted-whale-78169

    08/10/2022, 12:01 AM
    i plan on getting the basic game logic working and then add textures later
  • f

    faint-toothbrush-51643

    08/10/2022, 12:01 AM
    i'm not sure exactly how you're doing all this, but just remember that objects are positioned relative to their parent
  • g

    gifted-whale-78169

    08/10/2022, 12:01 AM
    Copy code
    Begin = new Text();
            Begin.content = "Begin";
            Begin.font = font;
            Begin.color = Color.CYAN;
            Begin.anchor(0.5, 0.5);
            Begin.scale(2.8, 2.8);
            Begin.pointSize = 20;
    
            Credits = new Text();
            Credits.content = "Credits";
            Credits.font = font;
            Credits.color = Color.GRAY;
            Credits.anchor(0.5, 0.5);
            Credits.scale(2.2, 2.2);
            Credits.pointSize = 20;
    
            scene.add(this);
            this.size(scene.width, scene.height / 4);
            this.pos(scene.width * 0.5, scene.height - 10);
            this.anchor(0.5, 1);
    
            Credits.align = CENTER;
            Credits.pos(width * 0.6, height * 0.5);
            this.add(Credits);
    
            Begin.align = CENTER;
            Begin.pos(width * 0.4, height * 0.5);
            this.add(Begin);
    is in my constructor for
    MenuOptions
    , both Begin and Credits are text
  • g

    gifted-whale-78169

    08/10/2022, 12:02 AM
    the MenuOptions itself has the same width as the scene with 1/4 height
  • f

    faint-toothbrush-51643

    08/10/2022, 12:03 AM
    when the scene's width is changed, it doesn't automatically change the MenuOptions's width
  • g

    gifted-whale-78169

    08/10/2022, 12:03 AM
    thats what i thought, which is why i also tried binding a function to the resize event
  • g

    gifted-whale-78169

    08/10/2022, 12:03 AM
    Copy code
    screen.onResize(scene, () -> {
                log.debug("resized apparently");
                this.size(scene.width, scene.height / 4);
                
            });
  • g

    gifted-whale-78169

    08/10/2022, 12:03 AM
    it didnt help either
  • f

    faint-toothbrush-51643

    08/10/2022, 12:04 AM
    my project resizes to different resolutions, but i don't use events
  • f

    faint-toothbrush-51643

    08/10/2022, 12:05 AM
    i think there might be a problem with how you're listening to
    screen
    resizing but you're resizing it based off `scene`'s size?
  • g

    gifted-whale-78169

    08/10/2022, 12:06 AM
    yea, once the window(screen) resizes i want it to resize to the updated width and height
  • g

    gifted-whale-78169

    08/10/2022, 12:06 AM
    it prints
    resized apparently
    but the width doesnt actually update
  • f

    faint-toothbrush-51643

    08/10/2022, 12:09 AM
    try doing this instead:
    Copy code
    hx
    this.size(screen.width, screen.height / 4);
  • f

    faint-toothbrush-51643

    08/10/2022, 12:09 AM
    also, quick tip, you can make discord color the code by putting in the file extension like this
  • g

    gifted-whale-78169

    08/10/2022, 12:10 AM
    ive been doing \`\`\`haxe instead and the color hasnt been showing up, thats probably why lol
  • g

    gifted-whale-78169

    08/10/2022, 12:10 AM
    let me try it
  • g

    gifted-whale-78169

    08/10/2022, 12:11 AM
    still has an offset after a resize
  • f

    faint-toothbrush-51643

    08/10/2022, 12:11 AM
    huh
  • g

    gifted-whale-78169

    08/10/2022, 12:13 AM
    it still has an offset
  • f

    faint-toothbrush-51643

    08/10/2022, 12:13 AM
    i saw
  • f

    faint-toothbrush-51643

    08/10/2022, 12:13 AM
    that's weird
  • g

    gifted-whale-78169

    08/10/2022, 12:13 AM
    oh i thought you said it like a question lmfao
  • f

    faint-toothbrush-51643

    08/10/2022, 12:14 AM
    something i do and would suggest if you care about resizing
  • f

    faint-toothbrush-51643

    08/10/2022, 12:15 AM
    it seems the way you're doing it now is that you have duplicate code in the creation/construction and in events
  • f

    faint-toothbrush-51643

    08/10/2022, 12:16 AM
    Copy code
    hx
        override function resize(w:Float, h:Float) {
            super.resize(w, h);
            justResized = true;
            if (cursor != null) {
                resizeStuff(w, h);
                cursor.resize();
            }
        }
    
        function resizeAndAutoConnect() {
            resizeStuff(screen.width, screen.height);
            autoConnectUI();
            cursor.resize();
        }
    
        function resizeStuff(w:Float, h:Float):Void {
            
        }
  • f

    faint-toothbrush-51643

    08/10/2022, 12:16 AM
    that's in
    PrexScene
    , an extension of Scene that all my other scenes extend, with some neat utility
  • f

    faint-toothbrush-51643

    08/10/2022, 12:17 AM
    Copy code
    hx
        override function create() {
            super.create();
            
            buttPlay = new PrexButton();
            buttPlay.addTextLang("mainmenu-play");
            add(buttPlay);
            buttPlay.onConfirm(this, playGame);
            
            buttCustom = new PrexButton();
            buttCustom.addTextLang("mainmenu-charCreator");
            add(buttCustom);
            buttCustom.onConfirm(this, doCustom);
    
            /*buttSettings = new PrexButton();
            buttSettings.addTextLang("mainmenu-settings");
            add(buttSettings);
            buttSettings.onConfirm(this, doSettings);*/
    
            buttExtras = new PrexButton();
            buttExtras.addTextLang("mainmenu-extras");
            add(buttExtras);
            buttExtras.onConfirm(this, doExtras);
    
    
            cursor.hoverTo(buttPlay);
    
            resizeAndAutoConnect();
        }
        
        override function resizeStuff(w, h) {
            buttPlay.resizeRect(width * .5, height * .2, 200, 40);
            buttCustom.resizeRect(width * .5, height * .4, 200, 40);
            //buttSettings.resizeRect(width * .5, height * .6, 200, 40);
            buttExtras.resizeRect(width * .5, height * .8, 200, 40);
        }
  • f

    faint-toothbrush-51643

    08/10/2022, 12:18 AM
    so i'm not putting the positioning and sizing stuff in both the creation and the resizing
  • f

    faint-toothbrush-51643

    08/10/2022, 12:18 AM
    it's the same thing
1...456...124Latest