From ecbe17b582803aaeaa9ccee88a3d093ff93a6cd3 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 21 Feb 2021 12:31:55 -0500 Subject: Added sprite pausing All sprites are now paused when a cutscene starts and unpaused when it ends. Pausing means that the CharacterSystem and BehaviourSystem will not process them in their tick. This allows specific sprites to be unpaused during cutscenes if movement is needed. The player character is halted and made non-controllable by the script when the cutscene starts and made controllable again when it ends. It is important to remember that if interacting with a sprite that might be moving, you have to manually call Halt() on them in their script to make them stop moving. --- res/scripts/common.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'res/scripts/common.lua') diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 4dfa1a2..494ace9 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua @@ -49,6 +49,11 @@ function StartCutscene() playerSprite.controllable = false character():halt(playerId) message():displayCutsceneBars() + + local allSprites = getAllSprites() + for k,v in pairs(allSprites) do + getSprite(v).paused = true + end end --- Queues a message for display. @@ -94,6 +99,11 @@ function HideCutsceneBars() local playerId = getPlayerSprite() local playerSprite = getSprite(playerId) playerSprite.controllable = true + + local allSprites = getAllSprites() + for k,v in pairs(allSprites) do + getSprite(v).paused = false + end end function GetPosition(spriteName) @@ -120,6 +130,11 @@ function WaitForAnimation(spriteName) until sprite.animFinished end +function Halt(spriteName) + local spriteId = getSpriteByAlias(spriteName) + character():halt(spriteId) +end + function PlaySound(filename) mixer():playSound("../res/sfx/" .. filename) end -- cgit 1.4.1