- Library instancing
- Runtime customizability
- Simplified API
- Optionality/Flexibility
- No state leaks
Scribe
Code: Select all
Scribe = require('scribe')
Scribe:update(dt)
Scribe:draw()
Scribe:write(<text>, <properties>)
Scribe:scroll(<text>, <properties>)
OtherScribe = Scribe.new() --new library instance.
<properties> is a table containing (optional) key/value pairs. The default property values are:
Code: Select all
--delay = 0.1
--linger = 1
--color = { 1,1,1,1 }
--x = 0
--y = 0
--width = love.graphics.getWidth()
--justify = 'left'
--scale = 1
--sounds = false
--font = love.graphics.getFont()
---- Scroll-Specific ----
--wait = 1
--speed = <delay>
--scroll_sounds = false
Most are self-explanatory, but a few properties are worth some explanation:
- delay is the time between each character rendering.
- linger is how long the text remains after the final character of the string is rendered.
- sounds is a valid love audio source or a table containing multiple love audio sources. The sound will play with each new character (excluding spaces) added to the string. If there are multiple sources, it will play one chosen randomly from the table.
Code: Select all
Waft = require('waft')
Waft:update(dt)
Waft:draw()
Waft:splat(<text>, <properties>)
Waft:set(<property>, <value>)
Waft:nudge(<property>, <value>)
OtherWaft = Waft.new() -- new library instance.
<properties> is a table containing (optional) key/value pairs, but it is expected that you will want to customize most of them.
:set changes the specified property for all instances currently rendered by Waft.
:nudge adds a value to the specified numeric property of all instances currently rendered by Waft.
The default property values are:
Code: Select all
--duration = 1,
--color = { 1,1,1,1 },
--x = love.math.random(0, love.graphics.getWidth()),
--y = love.math.random(0, love.graphics.getHeight()),
--dx = --random value between -100 and 100
--dy = --random value between -100 and 100
--rotation = 0,
--scale = 1,
--fade = { _in = 0.5, _out = 1}, --start of the fadeout, end of the fadeout.
--font = love.graphics.getFont()
In addition to the above, :write, :scroll, and :splat all return a handle to the created instance. You can capture it to customize any property at runtime, using the same :set and :nudge syntax. For example:
Code: Select all
local popup_1 = Waft:splat("Hello World")
function love.update(dt)
Waft:update(dt)
Waft:nudge('rotation', math.pi * dt) --All popups created by 'Waft' are rotated at runtime
popup_1:nudge('rotation', math.pi * dt) --Only this popup is rotated at runtime
end
Code: Select all
popup_1:set('x', 100) -- popup_1.props.x = 100
popup_1:nudge('x', 100) -- popup_1.props.x = popup_1.props.x + 100
You can find the code for the attached gifs on github. More in-depth documentation is being worked on, but honestly the APIs are super simple so it shouldn't be too hard to get them up-and-running.