It is this way because of it's cross-platform nature, it needs to be able to operate at the resolution of any of the devices it is run on.
It does this by having two sets of resolutions;
- Physical - which for windows is defined in setup.agc and for phones and tables is defined by the hardware of the device screen.
- Virtual - which is used to position objects on the screen
Add the following commands to the start of the project;
physWidth# = getDeviceWidth()
physHeight# = getDeviceHeight()
virtWidth# = getVirtualWidth()
virtHeight# = getVirtualHeight()
These simply get the values from the system and store them in four variables. The # at the end of the names indicates the values will be floating point values (numbers with fractions), rather than integers (whole numbers).
The physical resolution can't possible have fractions of pixels, but storing the values as if they can will force the maths to use floating point which will make scaling more accurate.
Remove the setDisplayAspect() command and replace the loop block with the following;
do
printc( "Physical: " )
print( str( physWidth# ) + " x " + str( physHeight# ) )
printc( "Virtual: " )
print( str( virtWidth# ) + " x " + str( virtHeight# ) )
sync()
loop
The str() command converts a value into a string to allow it to be joined to other strings (using the + ) for printing.
The complete project should now look like this;
Which should produce the following result.
To make it use the native resolution of the device, we use the setVirtualResolution() command, by adding the following at line 3;setVirtualResolution( physWidth# , physHeight# )
Like this;
and now we get;
Which is much better.
No comments:
Post a Comment