battlesystem: add relative cursor to new menu object
This commit is contained in:
parent
8f10c0dce8
commit
99feaf2be5
1 changed files with 19 additions and 3 deletions
|
@ -193,12 +193,28 @@ function CharacterMenu:new(scene, name, x, y)
|
|||
self.scene = scene
|
||||
local w, h = MENU_WIDTH, MENU_ITEM_NUMBER * MENU_ITEM_HEIGHT
|
||||
CharacterMenu.super.new(self, scene.menusystem, name, x, y, w, h, MENU_ITEM_NUMBER)
|
||||
self.cursorTexture = love.graphics.newImage("assets/gui/cursor-menulist.png")
|
||||
self.cursorTransition = 1
|
||||
end
|
||||
|
||||
function CharacterMenu:update(dt)
|
||||
CharacterMenu.super.update(self, dt)
|
||||
|
||||
local relativecursor = self.widget.selected - self.view.firstSlot
|
||||
|
||||
local transition = self.cursorTransition - relativecursor
|
||||
|
||||
if math.abs(transition) < 0.1 then
|
||||
self.cursorTransition = relativecursor
|
||||
else
|
||||
self.cursorTransition = (self.cursorTransition) + ((relativecursor) - (self.cursorTransition)) * dt*45
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function CharacterMenu:drawCursor()
|
||||
CharacterMenu.super.drawCursor(self)
|
||||
--local addition = 16
|
||||
--love.graphics.draw(self.cursorTexture, self.x - 12, self.y + (self.cursorTransition) * addition + 2 )
|
||||
local addition = 17
|
||||
love.graphics.draw(self.cursorTexture, self.x + 4, self.y + (self.cursorTransition) * addition )
|
||||
end
|
||||
|
||||
-- WIDGETS
|
||||
|
|
Loading…
Reference in a new issue