|
@@ -15,6 +15,7 @@ end
|
|
local button = {
|
|
local button = {
|
|
text = 'Please click me',
|
|
text = 'Please click me',
|
|
textSize = .1,
|
|
textSize = .1,
|
|
|
|
+ count = 0,
|
|
position = lovr.math.newVec3(0, 1, -3),
|
|
position = lovr.math.newVec3(0, 1, -3),
|
|
width = 1.0,
|
|
width = 1.0,
|
|
height = .4,
|
|
height = .4,
|
|
@@ -46,13 +47,16 @@ function lovr.update()
|
|
-- If the ray intersects the plane, do a bounds test to make sure the x/y position of the hit
|
|
-- If the ray intersects the plane, do a bounds test to make sure the x/y position of the hit
|
|
-- is inside the button, then mark the button as hover/active based on the trigger state.
|
|
-- is inside the button, then mark the button as hover/active based on the trigger state.
|
|
if inside then
|
|
if inside then
|
|
- if lovr.headset.wasPressed(hand, 'trigger') then
|
|
|
|
- print('ALERT: The button has been pressed')
|
|
|
|
- elseif lovr.headset.isDown(hand, 'trigger') then
|
|
|
|
|
|
+ if lovr.headset.isDown(hand, 'trigger') then
|
|
button.active = true
|
|
button.active = true
|
|
else
|
|
else
|
|
button.hover = true
|
|
button.hover = true
|
|
end
|
|
end
|
|
|
|
+
|
|
|
|
+ if lovr.headset.wasReleased(hand, 'trigger') then
|
|
|
|
+ button.count = button.count + 1
|
|
|
|
+ print('BOOP')
|
|
|
|
+ end
|
|
end
|
|
end
|
|
|
|
|
|
-- Set the end position of the pointer. If the raycast produced a hit position then use that,
|
|
-- Set the end position of the pointer. If the raycast produced a hit position then use that,
|
|
@@ -75,6 +79,7 @@ function lovr.draw()
|
|
-- Button text (add a small amount to the z to put the text slightly in front of button)
|
|
-- Button text (add a small amount to the z to put the text slightly in front of button)
|
|
lovr.graphics.setColor(1, 1, 1)
|
|
lovr.graphics.setColor(1, 1, 1)
|
|
lovr.graphics.print(button.text, button.position + vec3(0, 0, .001), button.textSize)
|
|
lovr.graphics.print(button.text, button.position + vec3(0, 0, .001), button.textSize)
|
|
|
|
+ lovr.graphics.print('Count: ' .. button.count, button.position + vec3(0, .5, 0), .1)
|
|
|
|
|
|
-- Pointers
|
|
-- Pointers
|
|
for hand, tip in pairs(tips) do
|
|
for hand, tip in pairs(tips) do
|