HTML5 canvas dimensions

I’ve put a little test project together that is working really nicely, but one thing that irks me is that when viewed in the browser the app always defaults to the full height of the browser.  Is there a way of constraining it to the dimensions specified in config.lua?

HTML5 is like Desktop apps. You specify a “window” key in build.settings and can control the default size of the screen in pixels there.  The config.lua file is for defining the virtual content area you want to use, not the actual pixel size.

See: https://docs.coronalabs.com/guide/distribution/win32Build/index.html#window-settings

It should honor most of the keys there, but I know the defaultViewWidth and defaultViewHeight work for sure.

Rob

Hmmm… Not sure what I’m doing wrong.

This is my build.settings :

settings = { window = { defaultViewWidth = 320, defaultViewHeight = 480, }, }

but it’s still resizing to full height of browser.

Hi,

You try it it with defaultMode = “normal” but unless it’s been fixed recently, it will “snap” to full browser size as soon as the window is resized. It sounds similar to this issue https://forums.coronalabs.com/topic/72264-how-to-keep-content-from-scaling-on-window-resize/

 window = { defaultMode = "normal", defaultViewWidth = 960, defaultViewHeight = 640, titleText = { default = "MyGame" } },

It is super annoying.  :huh:

EDIT: The resizable flag doesn’t seem to make any difference either.

-dev

I’ve pinged engineering but it is the weekend.

Rob

Cheers for the help guys.  Here’s what I’ve been noodling with…
http://www.aquietspace.org/modernretro/

The fix will come in next daily build:

when defaultMode = “normal” app will not be resized,

when defaultMode = “maximized” app will be resized to fit browser’s window.

FYI: html5 app ignores config.lua and uses settings from build.settings only

looks cool and mystically ))

Excellent :slight_smile:

Just to clarify, config.lua is still used to define your virtual content area, but it’s not used to determine the device screen size that the content area will be scaled too.

You still need a config.lua.

Rob

HTML5 is like Desktop apps. You specify a “window” key in build.settings and can control the default size of the screen in pixels there.  The config.lua file is for defining the virtual content area you want to use, not the actual pixel size.

See: https://docs.coronalabs.com/guide/distribution/win32Build/index.html#window-settings

It should honor most of the keys there, but I know the defaultViewWidth and defaultViewHeight work for sure.

Rob

Hmmm… Not sure what I’m doing wrong.

This is my build.settings :

settings = { window = { defaultViewWidth = 320, defaultViewHeight = 480, }, }

but it’s still resizing to full height of browser.

Hi,

You try it it with defaultMode = “normal” but unless it’s been fixed recently, it will “snap” to full browser size as soon as the window is resized. It sounds similar to this issue https://forums.coronalabs.com/topic/72264-how-to-keep-content-from-scaling-on-window-resize/

 window = { defaultMode = "normal", defaultViewWidth = 960, defaultViewHeight = 640, titleText = { default = "MyGame" } },

It is super annoying.  :huh:

EDIT: The resizable flag doesn’t seem to make any difference either.

-dev

I’ve pinged engineering but it is the weekend.

Rob

Cheers for the help guys.  Here’s what I’ve been noodling with…
http://www.aquietspace.org/modernretro/

The fix will come in next daily build:

when defaultMode = “normal” app will not be resized,

when defaultMode = “maximized” app will be resized to fit browser’s window.

FYI: html5 app ignores config.lua and uses settings from build.settings only

looks cool and mystically ))

Excellent :slight_smile:

Just to clarify, config.lua is still used to define your virtual content area, but it’s not used to determine the device screen size that the content area will be scaled too.

You still need a config.lua.

Rob