Skip to content

Size from System.windowWidth()/Height() different from what is passed in System.init() #16

Description

@RafaelOliveira

The size from System.windowWidth()/windowHeight() is different from what is passed in System.init() when you call the functions in the Project.hx constructor. Its showing a fixed size of 300x150. But if you call System.windowWidth()/windowHeight() after the assets are loaded the size will be correct, but only if there is assets to be loaded. Otherwise the size will be the wrong value.

  • VSCode Version: 16.8.0
  • OS Version: Windows 10

Steps to Reproduce:

  1. Execute the code below (this is just the Project.hx file), with an asset in the Assets folder, and without assets.
package;

import kha.Framebuffer;
import kha.Scheduler;
import kha.System;
import kha.Assets;

class Project
{
    public function new() 
    {
        trace('before load assets');
        trace('width: ' + System.windowWidth() + ' height: ' + System.windowHeight());

        Assets.loadEverything(assetsLoaded);        
    }

    function assetsLoaded():Void
    {
        trace('after load assets');
        trace('width: ' + System.windowWidth() + ' height: ' + System.windowHeight());

        System.notifyOnRender(render);
        Scheduler.addTimeTask(update, 0, 1 / 60);
    }

    function update():Void 
    {

    }

    function render(fb:Framebuffer):Void 
    {

    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions