Noble
A li'l game engine for Playdate.
Functions
- new(StartingScene[, __launcherTransitionDuration=1.5[, __launcherTransition=Noble.Transition.DipToBlack[, __launcherTransitionProperties={}[, __configuration={}[, __sceneProperties={}]]]]])
-
Engine initialization. Run this once in your main.lua file to begin your game.
Parameters
- StartingScene
NobleScene
This is the scene your game begins with, such as a title screen, loading screen, splash screen, etc. NOTE: Pass the scene's class name, not an instance of the scene. - __launcherTransitionDuration
number
= 1.5 (default)
If you want to transition from the final frame of your launch image sequence, enter a duration in seconds here. - __launcherTransition
Noble.Transition
= Noble.Transition.DipToBlack (default)
If a transition duration is set, use this transition type. - __launcherTransitionProperties
table
= {} (default)
Provide a table of properties to apply to the launcher transition. See the documentation for the transition you're using for a list of available properties. - __configuration
table
= {} (default)
Provide a table of Noble Engine configuration values. This will run Noble.setConfig for you at launch. - __sceneProperties
table
= {} (default)
A table consisting of user-defined properties which are passed into and handled by the new scene's init() method.
See
Usage
Noble.new( TitleScreen, 2, Noble.Transition.DipToWhite, { holdTime = 0, ease = Ease.outInQuad }, { defaultTransition = Noble.Transition.Imagetable, defaultTransitionDuration = 1.75, enableDebugBonkChecking = true, } )
- StartingScene
NobleScene
- engineInitialized()
-
This checks to see if Noble.new has been run. It is used internally to ward off bonks.
Returns
-
bool
See
- getConfig()
-
Retrieve miscellaneous Noble Engine configuration options / default values
Returns
-
A table of all configuration values
See
- setConfig(__configuration)
-
Optionally customize miscellaneous Noble Engine configuration options / default values. You may run this method to change these values during runtime.
Parameters
- __configuration
table
This is a table with your configuration values in it.
See
- __configuration
table
- resetConfig()
-
Reset miscellaneous Noble Engine configuration values to their defaults.
See
- transition(NewScene[, __duration=1.5[, __transition=Noble.TransitionType.DIP_TO_BLACK[, __transitionProperties={}[, __sceneProperties={}]]]])
-
Transition to a new scene (at the end of this frame).
This method will create a new scene, mark the previous one for garbage collection, and animate between them.
Additional calls to this method within the same frame (before the already-called transition begins), will override previous calls. Any calls to this method once a transition begins will be ignored until the transition completes.
Parameters
- NewScene
NobleScene
The scene to transition to. Pass the scene's class, not an instance of the scene. You always transition from Noble.currentScene - __duration
number
= 1.5 (default)
The length of the transition, in seconds. - __transition
Noble.Transition
= Noble.TransitionType.DIP_TO_BLACK (default)
If a transition duration is set, use this transition type. If not set, it will use the value ofconfiguration.defaultTransition
. - __transitionProperties
table
= {} (default)
A table consisting of properties for this transition. Properties not set here will use values that transition'sdefaultProperties
table. - __sceneProperties
table
= {} (default)
A table consisting of user-defined properties which are passed into and handled by the new scene's init() method.
See
Usage
Noble.transition(Level2, 1, Noble.Transition.CrossDissolve, { dither = Graphics.image.kDitherTypeDiagonalLine ease = Ease.outQuint } ) -- Noble.transition(Level2, 1, Noble.Transition.DipToBlack, { holdTime = 0.5, ease = Ease.outInElastic } ) -- Noble.transition(Level, 1, Noble.Transition.SlideOff, { x = 400, y = 150 rotation = 45 }, { levelName = "Level Two: The Second Level!" levelData = "levels/level2.json", } )
- NewScene
NobleScene
- currentScene()
-
Get the current scene object
Returns
- currentSceneName()
-
Get the name of the current scene
Returns
-
string
- isTransitioning()
-
Check to see if the game is transitioning between scenes.
Useful to control game logic that lives outside of a scene's
update()
method.Returns
-
bool
Tables
- configuration
-
Miscellaneous Noble Engine configuration options / default values.
This table cannot be edited directly. Use Noble.getConfig and Noble.setConfig.
Fields
- defaultTransition
Noble.Transition
= Noble.Transition.DipToBlack (default)
When running Noble.transition if the transition is unspecified, it will use this one. - defaultTransitionDuration
number
= 1.5 (default)
When running Noble.transition if the scene transition duration is unspecified, it will take this long in seconds. - enableDebugBonkChecking
boolean
= false (default)
Noble Engine-specific errors are called "Bonks." You can set this to true during development in order to check for more of them. However, it uses resources, so you will probably want to turn it off before release. - alwaysRedraw
boolean
= true (default)
This sets the Playdate SDK methodplaydate.graphics.sprite.setAlwaysRedraw
. See the Playdate SDK for details on how this function works, and the reasons you might want to set it as true or false for your project.
See
- defaultTransition
Noble.Transition
= Noble.Transition.DipToBlack (default)