hud cursor coordinates
This commit is contained in:
@@ -53,7 +53,7 @@ clay.contain = layout.contain;
|
||||
|
||||
clay.draw = function draw(fn)
|
||||
{
|
||||
var size = [prosperon.logical.x, prosperon.logical.y]
|
||||
var size = [prosperon.logical.width, prosperon.logical.height]
|
||||
lay_ctx.reset();
|
||||
boxes = [];
|
||||
var root = lay_ctx.item();
|
||||
|
||||
@@ -10,7 +10,10 @@ var clay_input = {}
|
||||
// boxes: array of box objects from clay.draw()
|
||||
// mousepos: {x, y} position to test
|
||||
// prev_state: previous input state for tracking changes
|
||||
clay_input.hit = function hit(boxes, mousepos, prev_state = {}) {
|
||||
clay_input.hit = function hit(boxes, mouse, prev_state = {}) {
|
||||
var mousepos = {...mouse}
|
||||
mousepos.x *= 640
|
||||
mousepos.y *= 360
|
||||
var hovered = null
|
||||
var clicked = null
|
||||
|
||||
|
||||
@@ -529,8 +529,11 @@ function poll_input() {
|
||||
event.key = input.keyname(event.key)
|
||||
}
|
||||
|
||||
if (event.type.startsWith('mouse_') && event.pos && event.pos.y)
|
||||
if (event.type.startsWith('mouse_') && event.pos && event.pos.y) {
|
||||
event.pos.y = -event.pos.y + win_size.height
|
||||
event.pos.y /= win_size.height
|
||||
event.pos.x /= win_size.width
|
||||
}
|
||||
|
||||
filteredEvents.push(event)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user