Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get actual screen size #40

Open
codetreras opened this issue Mar 7, 2020 · 3 comments
Open

Get actual screen size #40

codetreras opened this issue Mar 7, 2020 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@codetreras
Copy link

I'm not sure if this is an actual issue, but I want to create a Game Window that matches my actual Android screen size. I haven't been able to retrieve the actual size in pixels of my screen.

@codetreras codetreras changed the title Get actual size screen Get actual screen size Mar 7, 2020
@soywiz
Copy link
Member

soywiz commented Mar 7, 2020

I could add it, though normally you don't do it. The typical way is to define a virtual size for your application. For example 720x1280. Then there is an "extended"/"actual" virtual rect: https://github.com/korlibs/korge/blob/ff21596f9bbd69dc3eae15c1a843f2719a3da695/korge/src/commonMain/kotlin/com/soywiz/korge/view/Views.kt#L64

Then you can disable clipBorders: https://github.com/korlibs/korge/blob/ff21596f9bbd69dc3eae15c1a843f2719a3da695/korge/src/commonMain/kotlin/com/soywiz/korge/view/Views.kt#L100

The minesweeper sample shows how to adapt to a slightly different aspect ratio with a 800x600 virtual size:
https://github.com/korlibs/korge-samples/blob/3ced591e97950b3521fdb669e0a0afc82462ae42/sample-minesweeper/src/commonMain/kotlin/com/soywiz/korge/samples/minesweeper/main.kt#L15

scaleMode = ScaleMode.SHOW_ALL,
clipBorders = false

Then uses dockedTo: https://github.com/korlibs/korge-samples/blob/3ced591e97950b3521fdb669e0a0afc82462ae42/sample-minesweeper/src/commonMain/kotlin/com/soywiz/korge/samples/minesweeper/main.kt#L27
to attach some views to specific corners of the screen

@codetreras
Copy link
Author

Btw, what does clipborder does?

@soywiz
Copy link
Member

soywiz commented Mar 13, 2020

It is enabled by default, and what it does is to create a rectangle clip that effectively doesn't paint to those "borders" that get a background color paint when the window/screen aspect ratio doesn't match the virtual size.

The hello world defines a virtual size of 512x512. This is a aspect ratio of 1:1:
https://korge.soywiz.com/samples/korge-hello-world/index.html

So when the width is larger than the height, there are borders to the left and the right, and for the opposite, the borders are at the top and the bottom. Those borders are the grey area that doesn't include the korge logo.

@soywiz soywiz added the documentation Improvements or additions to documentation label Mar 25, 2020
@soywiz soywiz transferred this issue from korlibs/korge Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: Pending
Development

No branches or pull requests

2 participants