Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

DragonRuby Game Toolkit

An intuitive 2D game engine. Fast, cross-platform, tiny, hot loaded. · By DragonRuby

Mouse click coordinates seem incorrect when using grid.origin_center!

A topic by CoderDennis created Jun 09, 2019 Views: 239 Replies: 2
Viewing posts 1 to 3

I found code in the api_demo for how to respond to mouse clicks and was trying to get something to happen on screen at the point of a click.

I just spent a couple days trying to figure out why my mouse clicks weren't doing anything. I finally figured out how to debug the actual x and y that I was getting with the clicks and the x was always greater than 1280. I had been using args.grid.origin_center!, so the x range should have been -640 to +640. After removing the origin_center! call and going back to default origin it works just fine. Is this a known issue with origin center?

Developer

We’ll double check that behavior, but yes you’re correct. The mouse should be between +-640. 

Developer

This has been fixed and will be in the next release. If you want you can "patch it" using the following code:

mouse_x = inputs.mouse.position.x - grid.origin_x #temporary fix until the next release
mouse_y = inputs.mouse.position.y # this value is correct