How do I properly resize the window?

  • In one of the examples, a program consisted of a red square in the corner. When the window was resized, the block got smaller, and went off to the side if the aspect ratio didn't stay the same. I noticed this dosen't happen with the default project. Is this a bug, or is there some easy fix?

  • @Indigo-A

    The Views object have a scaleMode property. You can access the Views object for example with the Stage instance.

    stage!!.views.scaleAnchor = Anchor.TOP_LEFT
    stage!!.views.scaleMode = ScaleMode.NO_SCALE

    It's an enum, so you can try several options that fit your needs.
    By default it is like this:

    class Views {
    	var scaleMode: ScaleMode = ScaleMode.SHOW_ALL
    	var scaleAnchor = Anchor.MIDDLE_CENTER

    If your virtual viewport is 640x480, it will place a rectangle showing all the content in the center of the screen (by effectively not showing content on the left and the right because it has a rectangle clipping maintaining your content on the center).

    The Views property has several width (and height counterparts) properties:

    stage.views.actualVirtualWidth, stage.views.actualVirtualTop, stage.views.actualVirtualLeft
    • The virtualWidth and virtualHeight are the size the viewport of your game. For example 320x224.
    • The nativeWidth and nativeHeight are the size of the window. By default it matches the initial definition: Korge(width = 640, height = 480, bgcolor = Colors.DARKCYAN), but you can set the window size to a different value that your game coordinates: Korge(width = 640, height = 480, virtualWidth = 320, virtualHeight = 240, bgcolor = Colors.DARKCYAN).
    • The actualVirtualWidth and counter part + (actualVirtualTop, actualVirtualLeft, actualVirtualBottom, actualVirtualRight) are used to determine the extra space in your game scale that is part of the border. This is used for responsive games that even if have a virtual size, do not want to show borders when the actual native aspect ratio of the window/display doesn't match the virtual aspect ratio of the game.

    An example of use of this, is the DockingComponent:

    I still have to add this stuff to the documentation 🙂 , since KorGE includes much more than what's documented.

  • You should make that your first priority...
    I can see that KorGE is much more powerful than the documentation shows, but we'll never know how to use it if it isn't documented. Sorry I'm harping on this, but if you document thees things, it makes it much easier for us to make a great game 🙂 Good luck 🙂

  • Yeah, makes sense. My priority right now is fixing bugs and documenting, I had a couple of weeks without too much time for this, but I hope to have much more time this weekend and next week, so I'll try to advance the documentation and fix bugs as much as I can!

  • @soywiz It's still clipping though.
    There's a particle emitter where I circled. How can I get it in the view bounds?

  • If you can send me a private message with a small project with a sample reproducing the problem: the particle emitter and the specific configuration of the stage and the views, I can have a look and try to fix it since the particle emitter sample I have doesn't have that behaviour