Device scaling

It’s been on the cards for a while to allow zooming functionality within the games but it was pushed back to the queue as a future addition.

The realization
It’s now been realized that this is also tied in with how scaling will work which is essential for mobile devices. If scaling isn’t implemented then the sprites will be the same pixel size on all devices. The problem with this is that on devices with a high DPI will display a much smaller looking version of the image than on others. This also means that this would allow much more to be seen on screens of a higher resolution than those devices with a lower one.

The solution
The solution is pretty simple, we create a scale based on the devices DPI along with a manually adjusted scale and the height of the camera is adjusted based on this value. This means that no matter the device, the camera position will always be positioned to show around the same amount of the display.

This has caused a few issues which needed to be cleaned up. The positioning of elements needed to be shifted so point 0,0 goes from the top left to the centre of the stage. This keeps everything in the correct place no matter the height of the camera. This in turn meant that the hit testing of elements needed to be updated to match the new positions of the sprites as well the scale.