SceneTemplate.lua
-- -- SceneTemplate.lua -- -- Use this as a starting point for your game's scenes. -- Copy this file into your project's "scenes" directory, -- and then rename it. -- -- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -- !!! Rename 'SceneTemplate' to your scene's name in these first three lines. !!! -- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SceneTemplate = {} class("SceneTemplate").extends(NobleScene) local scene = SceneTemplate -- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -- It is recommended that you declare, but don't yet define, -- your scene-specific variables and methods here. Use "local" where possible. -- -- Examples: -- -- local variable1 = nil -- "Private" variable. It can only be accessed within this file. -- -- scene.variable2 = nil -- "Public" variable. -- When accessed outside this file, call it usingSceneTemplate.variable2
. -- When accessed inside a method in this file, you may also useself.variable2
. -- -- -- This is the background color of this scene. scene.backgroundColor = Graphics.kColorWhite -- This runs when your scene's object is created, which is the -- first thing that happens when transitioning away from another scene. -- Properties passed into this scene via Noble.transition or Noble.new -- should be handled here. function scene:init(__sceneProperties) scene.super.init(self) -- Your code here, e.g.: -- Global.thing = 100 -- variable1 = "some text" -- self.variable2 = __sceneProperties.variable2 -- ... end -- When transitioning from another scene, this runs as soon as this -- scene needs to be visible (this moment depends on which transition type is used). -- This is also the point where this scene becomes the 'currentScene' according to -- Noble Engine, and its update loop will begin executing on every frame. function scene:enter() scene.super.enter(self) -- Your code here end -- This runs once a transition from another scene is complete. -- This scene's input handler will be enabled at this point and -- The player will be able to interact with the scene. -- Use this method to begin this scene's game logic. function scene:start() scene.super.start(self) -- Your code here end -- This runs once per frame. function scene:update() scene.super.update(self) -- Your code here end -- This runs once per frame, and is meant for drawing code. function scene:drawBackground() scene.super.drawBackground(self) -- Your code here end -- This runs as as soon as a transition to another scene begins. function scene:exit() scene.super.exit(self) -- Your code here end -- This runs once a transition to another scene completes. function scene:finish() scene.super.finish(self) -- Your code here end function scene:pause() scene.super.pause(self) -- Your code here end function scene:resume() scene.super.resume(self) -- Your code here end -- Define the inputHandler for this scene here, or use a previously defined inputHandler. -- scene.inputHandler = someOtherInputHandler -- OR scene.inputHandler = { -- A button -- AButtonDown = function() -- Runs once when button is pressed. -- Your code here end, AButtonHold = function() -- Runs every frame while the player is holding button down. -- Your code here end, AButtonHeld = function() -- Runs after button is held for 1 second. -- Your code here end, AButtonUp = function() -- Runs once when button is released. -- Your code here end, -- B button -- BButtonDown = function() -- Your code here end, BButtonHeld = function() -- Your code here end, BButtonHold = function() -- Your code here end, BButtonUp = function() -- Your code here end, -- D-pad left -- leftButtonDown = function() -- Your code here end, leftButtonHold = function() -- Your code here end, leftButtonUp = function() -- Your code here end, -- D-pad right -- rightButtonDown = function() -- Your code here end, rightButtonHold = function() -- Your code here end, rightButtonUp = function() -- Your code here end, -- D-pad up -- upButtonDown = function() -- Your code here end, upButtonHold = function() -- Your code here end, upButtonUp = function() -- Your code here end, -- D-pad down -- downButtonDown = function() -- Your code here end, downButtonHold = function() -- Your code here end, downButtonUp = function() -- Your code here end, -- Crank -- cranked = function(change, acceleratedChange) -- Runs when the crank is rotated. See Playdate SDK documentation for details. -- Your code here end, crankDocked = function() -- Runs once when when crank is docked. -- Your code here end, crankUndocked = function() -- Runs once when when crank is undocked. -- Your code here end }