feat: sounds effects on dialog boxes
This commit is contained in:
parent
50eb613a53
commit
9e031c0d7d
3 changed files with 9 additions and 4 deletions
BIN
sonic-radiance.love/assets/sfx/talk.wav
Normal file
BIN
sonic-radiance.love/assets/sfx/talk.wav
Normal file
Binary file not shown.
|
@ -95,6 +95,7 @@ local Talkies = {
|
||||||
padding = 4,
|
padding = 4,
|
||||||
talkSound = nil,
|
talkSound = nil,
|
||||||
optionSwitchSound = nil,
|
optionSwitchSound = nil,
|
||||||
|
optionOnSelectSound = nil,
|
||||||
inlineOptions = true,
|
inlineOptions = true,
|
||||||
|
|
||||||
titleColor = {1, 1, 1},
|
titleColor = {1, 1, 1},
|
||||||
|
@ -151,6 +152,7 @@ function Talkies.say(title, messages, config)
|
||||||
thickness = config.thickness or Talkies.thickness,
|
thickness = config.thickness or Talkies.thickness,
|
||||||
talkSound = config.talkSound or Talkies.talkSound,
|
talkSound = config.talkSound or Talkies.talkSound,
|
||||||
optionSwitchSound = config.optionSwitchSound or Talkies.optionSwitchSound,
|
optionSwitchSound = config.optionSwitchSound or Talkies.optionSwitchSound,
|
||||||
|
optionOnSelectSound = config.optionOnSelectSound or Talkies.optionOnSelectSound,
|
||||||
inlineOptions = config.inlineOptions or Talkies.inlineOptions,
|
inlineOptions = config.inlineOptions or Talkies.inlineOptions,
|
||||||
font = font,
|
font = font,
|
||||||
fontHeight = font:getHeight(" "),
|
fontHeight = font:getHeight(" "),
|
||||||
|
@ -377,7 +379,7 @@ function Talkies.onAction()
|
||||||
else
|
else
|
||||||
if currentDialog:showOptions() then
|
if currentDialog:showOptions() then
|
||||||
currentDialog.options[currentDialog.optionIndex][2]() -- Execute the selected function
|
currentDialog.options[currentDialog.optionIndex][2]() -- Execute the selected function
|
||||||
playSound(currentDialog.optionSwitchSound)
|
playSound(currentDialog.optionOnSelectSound)
|
||||||
end
|
end
|
||||||
Talkies.advanceMsg()
|
Talkies.advanceMsg()
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,9 @@ local Talkies = require('core.libs.talkies')
|
||||||
function DialogBox:new(controller, args)
|
function DialogBox:new(controller, args)
|
||||||
DialogBox.super.new(self, controller, args)
|
DialogBox.super.new(self, controller, args)
|
||||||
Talkies.font = love.graphics.newFont("assets/gui/fonts/PixelOperator.ttf", 16)
|
Talkies.font = love.graphics.newFont("assets/gui/fonts/PixelOperator.ttf", 16)
|
||||||
|
Talkies.talkSound = love.audio.newSource("assets/sfx/talk.wav", "static")
|
||||||
|
Talkies.optionOnSelectSound = love.audio.newSource("assets/sfx/menus/select.wav", "static")
|
||||||
|
Talkies.optionSwitchSound = love.audio.newSource("assets/sfx/menus/beep.wav", "static")
|
||||||
end
|
end
|
||||||
|
|
||||||
function DialogBox:start()
|
function DialogBox:start()
|
||||||
|
@ -52,9 +55,9 @@ function DialogBox:update(dt)
|
||||||
self:finish()
|
self:finish()
|
||||||
end
|
end
|
||||||
local keys = self.events.scene.sources[1].keys
|
local keys = self.events.scene.sources[1].keys
|
||||||
if (keys["up"].isPressed) then Talkies.prevOption()
|
if (keys["up"].isPressed) then Talkies.prevOption();
|
||||||
elseif (keys["down"].isPressed) then Talkies.nextOption()
|
elseif (keys["down"].isPressed) then Talkies.nextOption();
|
||||||
elseif (keys["A"].isPressed) then Talkies.onAction()
|
elseif (keys["A"].isPressed) then Talkies.onAction();
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue