More complex example from stdgregwar:
this is the final custcene of Zelda XD2 rewritten with his script.
-- Final cinematic, but flat
function map:start_cinematic_redux()
cutscene.builder(game,map,hero)
.wait(500)
.dialog('final.zelda_4',player_name)
.set_direction(hero,1)
.dontWaitFor.hero_animation('walking')
.movement{ --movement 1
type='target',
entity=hero,
movement_properties={
target = {104,192},
speed = 50,
smooth = true,
ignore_obstacles = true,
}
}
.set_direction(hero,0)
.dontWaitFor.hero_animation('stopped')
.wait(500)
.dialog('final.zelda_5',player_name)
.wait(500)
.dialog('final.mr_grump_3')
.wait(500)
.dialog('final.zelda_6',player_name)
.set_direction(hero,2)
.dontWaitFor.hero_animation('walking')
.movement{--movement 2
type = 'target',
entity=hero,
movement_properties={
target = {-32,192},
speed = 80,
smooth = true,
ignore_obstacles = true
}
}
.wait(500)
.set_direction(hero,0)
.dontWaitFor.hero_animation('carrying_walking')
.dontWaitFor.sprite_animation(cocktails:get_sprite(),'walking')
.movement(--movement 3
{
type='target',
entity=hero,
movement_properties={
target = {104,192},
speed = 80,
smooth = true,
ignore_obstacles = true
}
},
function(mov)
function mov:on_position_changed()
if cocktails then
local hero_x,hero_y = hero:get_position()
cocktails:set_position(hero_x,hero_y-16)
end
end
end)
.dontWaitFor.hero_animation('carrying_stopped')
.dontWaitFor.sprite_animation(cocktails:get_sprite(),'on_ground')
.wait(1500)
.exec(
function()
cocktails:remove()
end)
.dontWaitFor.hero_animation('stopped')
.dialog('final.zelda_7',player_name)
.wait(500)
.dontWaitFor.hero_animation('dying')
.wait(2000)
.dontWaitFor.hero_animation('walking')
.set_direction(hero,2)
.movement{--movement 4
type='target',
entity=hero,
movement_properties = {
target = {-32,192},
speed = 80,
smooth = true,
ignore_obstacles = true
}
}
.wait(1000)
.dialog('final.zelda_8')
.wait(500)
.and_then(
function(cont)
fade_sprite = sol.sprite.create('entities/heart_fade')
local camera_x, camera_y = map:get_camera():get_position()
local zelda_x, zelda_y = grump_and_zelda:get_position()
fade_x = zelda_x - camera_x
fade_y = zelda_y - camera_y - 16
fade_sprite:set_animation('close',cont)
end)
.exec(
function()
-- Fill screen with black.
local quest_w, quest_h = sol.video.get_quest_size()
black_surface = sol.surface.create(quest_w, quest_h)
black_surface:fill_color({0, 0, 0})
end)
.wait(1000)
.exec(
function()
local menu_font, menu_font_size = language_manager:get_menu_font()
end_text = sol.text_surface.create{
horizontal_alignment = "center",
vertical_alignment = "middle",
color = {255, 255, 255},
font = menu_font,
font_size = menu_font_size * 2,
text_key = "final.end_text",
}
end)
.wait(2000)
.exec(
function()
-- Launch Ending credits.
local dialog_box = game:get_dialog_box()
dialog_box:set_position("bottom")
end)
.dialog('final.credits')
.exec(
function()
local statistics = statistics_manager:new(game)
game:set_suspended(true)
sol.menu.start(game, statistics)
function statistics:on_finished()
-- Reset game.
sol.main.reset()
end
end)
.start()
end