How to change game resolution, in-game?

MichaelPel

  • *
  • Posts: 458
I've built a simple game where all the huds, windows etc are dynamic and resolution dependant. Everything works brilliantly when I change the game's resolution in the settings before compiling. I'd like the user to be able to change resolution in-game. Is this possible?

MichaelPel

  • *
  • Posts: 458
Quick addition: I'd like to have a few resolution presets, and a game scale (1X, 2X, 3X or 4X) assigned to it. Having to reboot the game isn't a problem.

MichaelPel

  • *
  • Posts: 458

purplelava

  • Posts: 82
I was curious about that too, so I looked on Forge. There is a behavior called "iPad Resolution OpenFL" by Max Glocking, which shows how to get the current resolution in code: openfl.system.Capabilities.screenResolutionX or Y.

You should find the code on how to SET the resolution in the openfl API, and I guess you're done. Hopefully.

I am not a coder at all, so if you or somebody else finds out how to set resolution at runtime, I would like to know. Makes desktop games very professional.

MichaelPel

  • *
  • Posts: 458
I'll run this by my friend who does programming for a living, he might make sense of this for Stencyl use. Will tell what I end up with.

darrigaz

  • Posts: 124
Just for reference when people look this up in future (as I've just been doing). You can work around some of this with a fullscreen toggle and adjusting the scaling setting in game.

Run this bit of code.

com.stencyl.Config.gameScale = scale;
com.stencyl.Engine.engine.reloadScreen();

Scale is the same setting as in the settings tab you can make an attribute with that name or rename it to match another attribute. Then just change that attribute to resize the window. There's a "make fullscreen" block for toggling fullscreen and windowed mode.

NobleValerian

  • Posts: 2
Holy crap, over 2.5 years unanswered.  I've spent the entire day trying to solve issues like this that shouldn't be issues at all.  I don't understand why anyone should ever reply with code examples.  No one is using Stencyl because they want to deal with code, that's the whole point.  But with this and every alternative on the market failing on simple things in major ways, maybe the misery of coding is better than the misery of flawed Drag and Drop editors.

Majora64

  • Posts: 536
No one is using Stencyl because they want to deal with code, that's the whole point.

This is far from the truth. I am by no means a coding connoisseur but having used Stencyl for a few years now has taught me to delve deeper with actually trying to learn how everything works instead of strictly using blocks. Knowing some form of code or at least being able to interpret it (for learning or debugging) has helped open doors for myself as a game creator and I hope in time will do the same for you. It's not a matter of the software failing you (because drag and drop is as straight forward as it gets); moreover, it's a matter of being patient and willing to learn.

squeeb

  • Posts: 1617
No one is using Stencyl because they want to deal with code, that's the whole point.

This is far from the truth. I am by no means a coding connoisseur but having used Stencyl for a few years now has taught me to delve deeper with actually trying to learn how everything works instead of strictly using blocks. Knowing some form of code or at least being able to interpret it (for learning or debugging) has helped open doors for myself as a game creator and I hope in time will do the same for you. It's not a matter of the software failing you (because drag and drop is as straight forward as it gets); moreover, it's a matter of being patient and willing to learn.
^^ i second this, being able to use real code is the reason i like stencyl.. i started with stencyl.. learned some java and android.. came back and am able to do almost anything ive wanted to do. i dont have to worry about syntax or anything, and i dont want to learn coding for ios! Haha

combosmooth

  • Posts: 22
who knows if anyone will ever see this, but where do you write the code?? Like in what behaviour or what??

com.stencyl.Config.gameScale = scale;
com.stencyl.Engine.engine.reloadScreen();

Justin

  • *
  • Posts: 4716
Yeah, in a behavior/event. Wherever you want the screen to be updated.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)