add new samples
This commit is contained in:
58
samples/anim-sample.lua
Normal file
58
samples/anim-sample.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
local fmt = require "fmt"
|
||||
|
||||
function on_resume()
|
||||
ui:show_lines{
|
||||
"Tap to change text",
|
||||
"Tap to change text quick",
|
||||
"Tap to change text color",
|
||||
"Tap to change text and back",
|
||||
"Tap to typewriter",
|
||||
"Tap to karaoke",
|
||||
"Tap to blink",
|
||||
"Tap to move",
|
||||
"Tap to heartbeat",
|
||||
"Tap to shake",
|
||||
}
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
if idx == 1 then
|
||||
morph:change_text(idx, "Text changed")
|
||||
elseif idx == 2 then
|
||||
morph:change_text(idx, "Text changed", 0)
|
||||
elseif idx == 3 then
|
||||
morph:change_text(idx, fmt.red("Color changed"))
|
||||
elseif idx == 4 then
|
||||
morph:change_text(idx, "Text changed")
|
||||
morph:run_with_delay(1000, function ()
|
||||
morph:change_text(idx, "Type to change text and back")
|
||||
end)
|
||||
elseif idx == 5 then
|
||||
local tab = {}
|
||||
local text = "Wake up, Neo"
|
||||
for i=1,text:len() do
|
||||
table.insert(tab, fmt.green(text:sub(1, i)))
|
||||
end
|
||||
morph:change_text_seq(idx, tab, 100)
|
||||
elseif idx == 6 then
|
||||
local tab = {}
|
||||
local text = [[
|
||||
Yesterday
|
||||
All my troubles seemed so far away
|
||||
Now it looks as though they're here to stay
|
||||
Oh, I believe in yesterday
|
||||
]]
|
||||
for i=1,text:len() do
|
||||
table.insert(tab, fmt.blue(text:sub(1, i))..text:sub(i+1))
|
||||
end
|
||||
morph:change_text_seq(idx, tab, 100)
|
||||
elseif idx == 7 then
|
||||
anim:blink(idx)
|
||||
elseif idx == 8 then
|
||||
anim:move(idx, 100, 0)
|
||||
elseif idx == 9 then
|
||||
anim:heartbeat(idx)
|
||||
elseif idx == 10 then
|
||||
anim:shake(idx)
|
||||
end
|
||||
end
|
||||
38
samples/dice-widget.lua
Normal file
38
samples/dice-widget.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
-- foldable = "false"
|
||||
|
||||
local dices = {
|
||||
"fa:dice-one",
|
||||
"fa:dice-two",
|
||||
"fa:dice-three",
|
||||
"fa:dice-four",
|
||||
"fa:dice-five",
|
||||
"fa:dice-six",
|
||||
}
|
||||
|
||||
function on_resume()
|
||||
ui:show_buttons{
|
||||
"Roll the dice",
|
||||
"fa:dice-six",
|
||||
"fa:dice-six",
|
||||
}
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
if idx == 1 then
|
||||
roll_dice(2)
|
||||
roll_dice(3)
|
||||
else
|
||||
roll_dice(idx)
|
||||
end
|
||||
end
|
||||
|
||||
function roll_dice(idx)
|
||||
local tab = {}
|
||||
|
||||
for i=1,10 do
|
||||
table.insert(tab, dices[math.random(1, 6)])
|
||||
end
|
||||
|
||||
morph:change_text_seq(idx, tab, 150)
|
||||
end
|
||||
|
||||
37
samples/star-wars.lua
Normal file
37
samples/star-wars.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
local text = [[
|
||||
It is a period of civil war.
|
||||
Rebel spaceships, striking
|
||||
from a hidden base, have won
|
||||
their first victory against
|
||||
the evil Galactic Empire.
|
||||
|
||||
During the battle, Rebel
|
||||
spies managed to steal secret
|
||||
plans to the Empire's
|
||||
ultimate weapon, the DEATH
|
||||
STAR, an armored space
|
||||
station with enough power to
|
||||
destroy an entire planet.
|
||||
|
||||
Pursued by the Empire's
|
||||
sinister agents, Princess
|
||||
Leia races home aboard her
|
||||
starship, custodian of the
|
||||
stolen plans that can save
|
||||
her people and restore
|
||||
freedom to the galaxy....
|
||||
]]
|
||||
|
||||
function on_resume()
|
||||
ui:show_text("Start")
|
||||
end
|
||||
|
||||
function on_click()
|
||||
local tab = {}
|
||||
|
||||
for i=1,text:len() do
|
||||
table.insert(tab, "%%txt%%"..text:sub(1, i))
|
||||
end
|
||||
|
||||
morph:change_text_seq(1, tab, 100)
|
||||
end
|
||||
Reference in New Issue
Block a user