Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added self.background_speed for shops #306

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mods/example/scripts/shops/mousehole.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
5 changes: 4 additions & 1 deletion src/engine/game/shop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -170,7 +171,8 @@ function Shop:init()
}
end

self.background = "ui/shop/bg_seam"
self.background = nil
self.background_speed = 5/30

self.state = "NONE"
self.state_reason = nil
Expand Down Expand Up @@ -250,6 +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, true)
self:addChild(self.background_sprite)
end

Expand Down