cursors
This commit is contained in:
parent
101ba11709
commit
c4d1846765
5 changed files with 28 additions and 1 deletions
BIN
assets/sprites/cursor/dragging.png
Normal file
BIN
assets/sprites/cursor/dragging.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/sprites/cursor/hand.png
Normal file
BIN
assets/sprites/cursor/hand.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/sprites/cursor/pointer.png
Normal file
BIN
assets/sprites/cursor/pointer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
7
main.lua
7
main.lua
|
@ -20,6 +20,7 @@ sprites = {}
|
||||||
sound_path = {}
|
sound_path = {}
|
||||||
music_path = {}
|
music_path = {}
|
||||||
fonts = {}
|
fonts = {}
|
||||||
|
cursors = {}
|
||||||
|
|
||||||
debug = false
|
debug = false
|
||||||
|
|
||||||
|
@ -48,6 +49,12 @@ function love.load()
|
||||||
fonts.default = love.graphics.newFont(12)
|
fonts.default = love.graphics.newFont(12)
|
||||||
|
|
||||||
if scene.load then scene.load() end
|
if scene.load then scene.load() end
|
||||||
|
|
||||||
|
cursors.default = love.mouse.newCursor('assets/sprites/cursor/pointer.png', sprites['cursor/pointer']:getWidth()/2, sprites['cursor/pointer']:getHeight()/2)
|
||||||
|
cursors.hover = love.mouse.newCursor('assets/sprites/cursor/hand.png', sprites['cursor/hand']:getWidth()/2, sprites['cursor/hand']:getHeight()/2)
|
||||||
|
cursors.drag = love.mouse.newCursor('assets/sprites/cursor/dragging.png', sprites['cursor/dragging']:getWidth()/2, sprites['cursor/dragging']:getHeight()/2)
|
||||||
|
|
||||||
|
love.mouse.setCursor(cursors.default)
|
||||||
end
|
end
|
||||||
|
|
||||||
frame = 0
|
frame = 0
|
||||||
|
|
|
@ -106,9 +106,29 @@ end
|
||||||
|
|
||||||
function self.update(dt)
|
function self.update(dt)
|
||||||
bench.startBenchmark('update_buttons')
|
bench.startBenchmark('update_buttons')
|
||||||
for _,btn in ipairs(headerbuttons) do
|
|
||||||
|
local x = 19
|
||||||
|
local y = 3
|
||||||
|
local anyhover = false
|
||||||
|
for b,btn in ipairs(headerbuttons) do
|
||||||
btn.openanim = btn.openanim + dt * 6
|
btn.openanim = btn.openanim + dt * 6
|
||||||
|
local size = (love.graphics.getWidth()/640)
|
||||||
|
local hovered = mouseOverBox(x * size, y * size, sprites['header/buttonbg']:getWidth() * size, sprites['header/buttonbg']:getHeight() * size)
|
||||||
|
|
||||||
|
if btn.open and hovered then
|
||||||
|
love.mouse.setCursor(cursors.hover)
|
||||||
|
anyhover = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local incr = 69 -- its like button positions but forcefully shoved into a recursive function :D
|
||||||
|
if b == 2 then incr = 57 end
|
||||||
|
if b >= 3 then incr = 73 end
|
||||||
|
x = x + incr
|
||||||
|
end
|
||||||
|
if not anyhover then
|
||||||
|
love.mouse.setCursor(cursors.default)
|
||||||
|
end
|
||||||
|
|
||||||
bench.stopBenchmark('update_buttons')
|
bench.stopBenchmark('update_buttons')
|
||||||
|
|
||||||
bench.startBenchmark('update_food')
|
bench.startBenchmark('update_food')
|
||||||
|
|
Loading…
Reference in a new issue