I have problems with backbuffer, screen resize and mouse position.
I create a backbuffer for rendering everything in the size 800/600 and then scale it to the framebuffer like in the kha shmup tutorial or in Lewis Leptons Kha Tutorial #23
framebuffer.g2.begin(); Scaler.scale(backbuffer,framebuffer,System.screenRotation); framebuffer.g2.end();
everything works great!
I am also using the full-page canvas from the wiki (https://github.com/Kode/Kha/wiki/HTML5)
Now i want to add a rectangle under the mousecursor on click.
To calculate the mouse coordinates to the backbuffer coordinates i do
var normalizeX:Float = x / System.windowWidth() * Game.backbuffer.width; var normalizeY:Float = y / System.windowHeight() * Game.backbuffer.height;
everything works fine if the backbuffer size = window size.
if change the windowsize it's acting wrong. What am I missing?
Here is a Kodegarden example http://kodegarden.org/#193ab6da06c02f70892cc3bfd7a957c8f3efaf41
just run it and change the size of the browser window.
or here is a example of my work with the full-page canvas http://jug.korbel.tech/
Thanks for the tips and help!