Bevy version
[dependencies]
bevy = "0.12.0"
bevy_embedded_assets = "0.9.1"
rand = "0.8.5"
wasm-bindgen = "0.2.88"
Relevant system information
- the Rust version you're using (you can get this by running
cargo --version)
cargo 1.73.0 (9c4383fb5 2023-08-26)
- the operating system or browser used, including its version
MacOS Sonoma 14.1.1 (23B81)
- Browser: Chrome
What you did
I get the position of a touch like this:
let just_pressed = touches.iter().find(|t| touches.just_pressed(t.id()));
let touch_pos = just_pressed.unwrap().position();
println!("touch at ({},{})", touch_pos.x, touch_pos.y);
then build using this script
APP_NAME="sokoban"
cargo build --release --target wasm32-unknown-unknown
wasm-bindgen --out-dir 'out/webgl' --target web "target/wasm32-unknown-unknown/release/${APP_NAME}.wasm"
open "out/webgl"
What went wrong
touching the top right of the screen (640x480) produces the coordinates (19,218)
You can experience this by trying to press the buttons on the live version of the game on my website while using the mobile emulator for chrome.... You will have to tap about half way up the screen in order to press the buttons on the menus.
Additional information
The coordinates are off by about half the screen height, maybe it has to do with the grid originating from the middle of the screen rather than the top?

Bevy version
Relevant system information
cargo --version)cargo 1.73.0 (9c4383fb5 2023-08-26)MacOS Sonoma 14.1.1 (23B81)What you did
I get the position of a touch like this:
then build using this script
What went wrong
touching the top right of the screen (640x480) produces the coordinates (19,218)
You can experience this by trying to press the buttons on the live version of the game on my website while using the mobile emulator for chrome.... You will have to tap about half way up the screen in order to press the buttons on the menus.
Additional information
The coordinates are off by about half the screen height, maybe it has to do with the grid originating from the middle of the screen rather than the top?