From 033e9a8af7baffa6e740ccc4219a6403bb321b80 Mon Sep 17 00:00:00 2001 From: FireRainV Date: Mon, 30 Dec 2024 19:39:12 +0200 Subject: [PATCH 1/2] Added self.background_speed for shops Sets the animation speed of the background, defaults to 5/30. --- mods/example/scripts/shops/mousehole.lua | 2 +- src/engine/game/shop.lua | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/example/scripts/shops/mousehole.lua b/mods/example/scripts/shops/mousehole.lua index 4fed333cc..6d26fb44e 100644 --- a/mods/example/scripts/shops/mousehole.lua +++ b/mods/example/scripts/shops/mousehole.lua @@ -31,6 +31,7 @@ function MouseHole:init() self.sell_options_text["storage"] = "Let's see what ya got." self.background = "shops/mousehole_background" + self.background_speed = 5/30 self.shopkeeper:setActor("shopkeepers/amelia") self.shopkeeper.sprite:setPosition(0, 8) @@ -48,7 +49,6 @@ end function MouseHole:postInit() super.postInit(self) - self.background_sprite:play(5/30, true) self.shopkeeper:setLayer(SHOP_LAYERS["above_boxes"]) end diff --git a/src/engine/game/shop.lua b/src/engine/game/shop.lua index ff1c70776..3fd56b762 100644 --- a/src/engine/game/shop.lua +++ b/src/engine/game/shop.lua @@ -57,6 +57,7 @@ --- ---@field background string The filepath of the background texture for this shop, relative to `assets/sprites` ---@field background_sprite Sprite The Sprite instance used to control the background. Not defined in `Shop:init()`. +---@field background_speed number The animation speed of the background texture. --- ---@field shop_music string The filepath of the song to play in this shop, relative to `assets/music` ---@field music Music The `Music` instance used to control the shop's music @@ -170,7 +171,7 @@ function Shop:init() } end - self.background = "ui/shop/bg_seam" + self.background = nil self.state = "NONE" self.state_reason = nil @@ -250,6 +251,7 @@ function Shop:postInit() self.background_sprite = Sprite(self.background, 0, 0) self.background_sprite:setScale(2, 2) self.background_sprite.layer = SHOP_LAYERS["background"] + self.background_sprite:play(self.background_speed or 5/30, true) self:addChild(self.background_sprite) end From 483c66c4a60d759d9b5af13b0ccf405bec819839 Mon Sep 17 00:00:00 2001 From: FireRainV Date: Mon, 30 Dec 2024 19:40:49 +0200 Subject: [PATCH 2/2] defined in init --- src/engine/game/shop.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/game/shop.lua b/src/engine/game/shop.lua index 3fd56b762..b71de9599 100644 --- a/src/engine/game/shop.lua +++ b/src/engine/game/shop.lua @@ -172,6 +172,7 @@ function Shop:init() end self.background = nil + self.background_speed = 5/30 self.state = "NONE" self.state_reason = nil @@ -251,7 +252,7 @@ function Shop:postInit() self.background_sprite = Sprite(self.background, 0, 0) self.background_sprite:setScale(2, 2) self.background_sprite.layer = SHOP_LAYERS["background"] - self.background_sprite:play(self.background_speed or 5/30, true) + self.background_sprite:play(self.background_speed, true) self:addChild(self.background_sprite) end