Change windowed resolution at runtime


  • Posts: 162
I just figured this out and thought it might be useful to someone, so I thought I'd share it. There's probably a better way to do this, but if you want to change your windowed resolution while the game is running(e.g.  you want to include resolution options for the player), this is what I figured out, and it gets the job done.

*Note: Fullscreen shaders will use the original dimensions of the window, and thus don't work properly if you make the window larger. I don't know how to fix that. :( There are probably other problems with this aswell.*

You're going to need to make a code mode behavior, because you have to import openfl.display.StageScaleMode;

To change the resolution use the following code:

And that's it.

EDIT: alternatively, you can do this-
Engine.engine.root.scaleX = newScale;
Engine.engine.root.scaleY = newScale;
Engine.screenScaleX = newScale;
Engine.screenScaleY = newScale;

The number you replace newScale with multiplies the original size(i.e. if you put 2 there, the graphics will be twice as big)

« Last Edit: December 26, 2015, 10:49:56 pm by MiscEtc »


  • *
  • Posts: 4133
You can also import stuff in a design mode behavior in the "Custom Import" event.

For Live Support: Join our discord channel and ping me @justin.


  • Posts: 162
@Justin- Thanks, I didn't notice that was there until now.


  • *
  • Posts: 458
Sorry for necroing an old thread, but I'm confused.
How can I use the code in an actual event? Importing just... imports. If I'd like to have an always if X then *resolution changing code*, how should I do it? Thanks!