KodeStudio icon indicating copy to clipboard operation
KodeStudio copied to clipboard

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

Open RafaelOliveira opened this issue 8 years ago • 0 comments

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 
    {

    }
}

RafaelOliveira avatar Sep 07 '16 05:09 RafaelOliveira