battlesystem: add relative cursor to new menu object

This commit is contained in:
Kazhnuz 2019-03-31 16:51:58 +02:00
parent 8f10c0dce8
commit 99feaf2be5

View file

@ -193,12 +193,28 @@ function CharacterMenu:new(scene, name, x, y)
self.scene = scene self.scene = scene
local w, h = MENU_WIDTH, MENU_ITEM_NUMBER * MENU_ITEM_HEIGHT 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) 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 end
function CharacterMenu:drawCursor() function CharacterMenu:drawCursor()
CharacterMenu.super.drawCursor(self) local addition = 17
--local addition = 16 love.graphics.draw(self.cursorTexture, self.x + 4, self.y + (self.cursorTransition) * addition )
--love.graphics.draw(self.cursorTexture, self.x - 12, self.y + (self.cursorTransition) * addition + 2 )
end end
-- WIDGETS -- WIDGETS