From 99feaf2be571e47148e532d20433cf5597159b75 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 31 Mar 2019 16:51:58 +0200 Subject: [PATCH] battlesystem: add relative cursor to new menu object --- .../scenes/battlesystem/controller/menu.lua | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/sonic-radiance.love/scenes/battlesystem/controller/menu.lua b/sonic-radiance.love/scenes/battlesystem/controller/menu.lua index b523a1b..7b9262a 100644 --- a/sonic-radiance.love/scenes/battlesystem/controller/menu.lua +++ b/sonic-radiance.love/scenes/battlesystem/controller/menu.lua @@ -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