DeviceWidth() and Flash

Monkey Forums/Monkey Programming/DeviceWidth() and Flash

Grey Alien(Posted 2011) [#1]
Hi there, sorry to keep asking noob questions. (also I now realise this should be in the Flash forum, sorry)

So my game reads DeviceWidth() and DeviceHeight() in Method OnCreate:Int() of MyApp and in HTML 5 those values are 800x600 because that's what I set in MonkeyGame.html in the HTML5 build folder.

However those values are 640x480 when I compile for Flash even though I've set this line: <embed src="MonkeyGame.swf" width="800" height="600" wmode="direct"> in MonkeyGame.html in the Flash build folder.

What's up with that? The result is my game looks horrible even though the Flash game appears to be 800x600 in the browser. The 800x600 background I'm loading in and all the text I draw has been slightly corrupted like it was downscaled then upscaled or something.


GfK(Posted 2011) [#2]
I think you may need to edit monkeygame.as and change the width and height in there. Because otherwise what you're doing (as I understand it), is running a game in 640x480 and scaling it up to 800x600, rather than running in native 800x600.


Grey Alien(Posted 2011) [#3]
Good tip, will check out thx.

[EDIT]Yep that totally worked thanks! I'm glad it doesn't get overwritten by monkey.

Next question: is there a way to centre the game horizontally in the browser?


Dima(Posted 2011) [#4]
Whats up Grey! it's hrdnutz <-

You would center flash and html5 canvas inside MonkeyGame.html in the build folder. You can edit the html file any way you want, so throw embed in a table or apply css to style the content.


Grey Alien(Posted 2011) [#5]
OK cool, thanks Dima!