Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- The animation file is generated with Panthera Animation Software
- -- https://insality.github.io/panthera-editor/editor
- local PantheraAnimation = {}
- local ALPHA = "color.w"
- local COLOR_X = "color.x"
- local COLOR_Y = "color.y"
- local COLOR_Z = "color.z"
- local POSITION_X = "position.x"
- local POSITION_Y = "position.y"
- local ROTATION_X = "rotation.x"
- local ROTATION_Y = "rotation.y"
- local ROTATION_Z = "rotation.z"
- local SCALE_X = "scale.x"
- local SCALE_Y = "scale.y"
- local SIZE_X = "size.x"
- local SIZE_Y = "size.y"
- local SLICE9_W = "slice9.w"
- local SLICE9_X = "slice9.x"
- local SLICE9_Y = "slice9.y"
- local SLICE9_Z = "slice9.z"
- ---@param nodes table<string, Node>|nil @If nil, it will try to get options.get_node(id) or gui.get_node(id)
- ---@param options table|nil @Animation params. Fields: is_loop, speed, callback, is_relative, callback_event, get_node
- function PantheraAnimation.start(nodes, options)
- local get_node = options and options.get_node or gui.get_node
- nodes = nodes or {}
- nodes["node"] = nodes["node"] or get_node("node")
- nodes["node1"] = nodes["node1"] or get_node("node1")
- nodes["node2"] = nodes["node2"] or get_node("node2")
- nodes["node3"] = nodes["node3"] or get_node("node3")
- ---@type panthera_animation
- local panthera_animation = {}
- panthera_animation.timers = {}
- panthera_animation.nodes = nodes
- panthera_animation.current_time = 0
- panthera_animation.is_playing = false
- panthera_animation.animation_time = 3
- panthera_animation.is_loop = options and options.is_loop or false
- panthera_animation.callback = options and options.callback or nil
- panthera_animation.speed = math.max(options and options.speed or 1, 0)
- panthera_animation.is_relative = options and options.is_relative or false
- panthera_animation.callback_event = options and options.callback_event or function() end
- panthera_animation.properties = {}
- panthera_animation.properties["node"] = { ROTATION_Z, SCALE_X, SCALE_Y }
- panthera_animation.properties["node1"] = { ALPHA, COLOR_X, COLOR_Y, COLOR_Z, POSITION_Y, ROTATION_X, ROTATION_Y, ROTATION_Z, SIZE_X, SIZE_Y }
- panthera_animation.properties["node2"] = { COLOR_X, COLOR_Y, COLOR_Z }
- panthera_animation.properties["node3"] = { POSITION_X, POSITION_Y, ROTATION_Z, SIZE_X, SIZE_Y, SLICE9_W, SLICE9_X, SLICE9_Y, SLICE9_Z }
- PantheraAnimation.play(panthera_animation)
- return panthera_animation
- end
- ---@param panthera_animation panthera_animation
- ---@return nil
- function PantheraAnimation.stop(panthera_animation)
- for node_name, properties in pairs(panthera_animation.properties) do
- for index = 1, #properties do
- gui.cancel_animation(panthera_animation.nodes[node_name], properties[index])
- end
- end
- for index = #panthera_animation.timers, 1, -1 do
- timer.cancel(panthera_animation.timers[index])
- table.remove(panthera_animation.timers, index)
- end
- panthera_animation.is_playing = false
- end
- ---@param panthera_animation panthera_animation
- ---@return nil
- function PantheraAnimation.play(panthera_animation)
- local nodes = panthera_animation.nodes
- local speed = panthera_animation.speed
- local timers = panthera_animation.timers
- local is_relative = panthera_animation.is_relative
- panthera_animation.is_playing = true
- if #timers > 0 then
- PantheraAnimation.stop(panthera_animation)
- end
- -- Node: node
- local node_node = nodes["node"]
- local node_node_scale = vmath.vector3(1, 1, 1)
- local node_node_rotation = vmath.vector3(0, 0, 0)
- if is_relative then
- node_node_scale = gui.get_scale(node_node)
- node_node_rotation = gui.get_rotation(node_node)
- else
- gui.set_scale(node_node, node_node_scale)
- gui.set_rotation(node_node, node_node_rotation)
- gui.play_flipbook(node_node, "defold-logo")
- end
- -- ROTATION_Z
- gui.animate(node_node, ROTATION_Z, node_node_rotation.z - 20, gui.EASING_OUTCUBIC, 0.22 / speed, 0.66 / speed, function()
- gui.animate(node_node, ROTATION_Z, node_node_rotation.z + 20, gui.EASING_OUTCUBIC, 0.24 / speed, 0 / speed, function()
- gui.animate(node_node, ROTATION_Z, node_node_rotation.z - 20, gui.EASING_OUTQUAD, 0.24 / speed, 0 / speed, function()
- gui.animate(node_node, ROTATION_Z, node_node_rotation.z + 20, gui.EASING_OUTQUAD, 0.24 / speed, 0 / speed, function()
- gui.animate(node_node, ROTATION_Z, node_node_rotation.z, gui.EASING_OUTCUBIC, 0.22 / speed)
- end)
- end)
- end)
- end)
- -- SCALE_X
- gui.animate(node_node, SCALE_X, node_node_scale.x + 0.5, gui.EASING_OUTSINE, 0.5 / speed, 0 / speed, function()
- gui.animate(node_node, SCALE_X, node_node_scale.x, gui.EASING_OUTBACK, 0.25 / speed, 0 / speed, function()
- gui.animate(node_node, SCALE_X, node_node_scale.x - 0.2, gui.EASING_OUTSINE, 0.26 / speed, 1.13 / speed, function()
- gui.animate(node_node, SCALE_X, node_node_scale.x + 0.7, gui.EASING_OUTEXPO, 0.5 / speed)
- end)
- end)
- end)
- -- SCALE_Y
- gui.animate(node_node, SCALE_Y, node_node_scale.y + 0.5, gui.EASING_OUTSINE, 0.5 / speed, 0 / speed, function()
- gui.animate(node_node, SCALE_Y, node_node_scale.y, gui.EASING_OUTBACK, 0.25 / speed, 0 / speed, function()
- gui.animate(node_node, SCALE_Y, node_node_scale.y - 0.2, gui.EASING_OUTSINE, 0.26 / speed, 1.13 / speed, function()
- gui.animate(node_node, SCALE_Y, node_node_scale.y + 0.7, gui.EASING_OUTBACK, 0.5 / speed)
- end)
- end)
- end)
- -- TRIGGER_EVENT
- table.insert(timers, timer.delay(0.31 / speed, false, function()
- panthera_animation.callback_event(node_node, "hi", 0)
- end))
- table.insert(timers, timer.delay(1.01 / speed, false, function()
- panthera_animation.callback_event(node_node, "wow", 0)
- end))
- table.insert(timers, timer.delay(1.74 / speed, false, function()
- panthera_animation.callback_event(node_node, "yea!", 0)
- end))
- -- TRIGGER_SET_IMAGE
- table.insert(timers, timer.delay(0.66 / speed, false, function()
- gui.play_flipbook(node_node, "letter_d")
- end))
- table.insert(timers, timer.delay(0.88 / speed, false, function()
- gui.play_flipbook(node_node, "letter_e")
- end))
- table.insert(timers, timer.delay(1.12 / speed, false, function()
- gui.play_flipbook(node_node, "letter_f")
- end))
- table.insert(timers, timer.delay(1.36 / speed, false, function()
- gui.play_flipbook(node_node, "letter_o")
- end))
- table.insert(timers, timer.delay(1.6 / speed, false, function()
- gui.play_flipbook(node_node, "letter_l")
- end))
- table.insert(timers, timer.delay(1.82 / speed, false, function()
- gui.play_flipbook(node_node, "letter_d")
- end))
- table.insert(timers, timer.delay(2.14 / speed, false, function()
- gui.play_flipbook(node_node, "defold-logo")
- end))
- -- Node: node1
- local node_node1 = nodes["node1"]
- local node_node1_position = vmath.vector3(0, 250, 0)
- local node_node1_rotation = vmath.vector3(0, 0, 0)
- local node_node1_color = vmath.vector4(0, 0, 0, 0.26750001311302)
- local node_node1_size = vmath.vector3(40, 40, 0)
- if is_relative then
- node_node1_position = gui.get_position(node_node1)
- node_node1_rotation = gui.get_rotation(node_node1)
- node_node1_size = gui.get_size(node_node1)
- else
- gui.set_position(node_node1, node_node1_position)
- gui.set_rotation(node_node1, node_node1_rotation)
- gui.set_color(node_node1, node_node1_color)
- gui.set_size(node_node1, node_node1_size)
- end
- -- ALPHA
- gui.animate(node_node1, ALPHA, node_node1_color.w, gui.EASING_OUTSINE, 0 / speed, 0 / speed, function()
- gui.animate(node_node1, ALPHA, node_node1_color.w + 0.732, gui.EASING_OUTBACK, 0.33 / speed, 0.18 / speed)
- end)
- -- COLOR_X
- gui.animate(node_node1, COLOR_X, node_node1_color.x + 1, gui.EASING_OUTSINE, 0.27 / speed)
- -- COLOR_Y
- gui.animate(node_node1, COLOR_Y, node_node1_color.y + 1, gui.EASING_OUTSINE, 0.27 / speed)
- -- COLOR_Z
- gui.animate(node_node1, COLOR_Z, node_node1_color.z + 1, gui.EASING_OUTSINE, 0.27 / speed)
- -- POSITION_Y
- gui.animate(node_node1, POSITION_Y, node_node1_position.y - 150, gui.EASING_OUTSINE, 2 / speed, 0 / speed, function()
- gui.animate(node_node1, POSITION_Y, node_node1_position.y, gui.EASING_OUTBACK, 1 / speed)
- end)
- -- ROTATION_X
- gui.animate(node_node1, ROTATION_X, node_node1_rotation.x + 360, gui.EASING_OUTSINE, 0.6 / speed, 0.9 / speed)
- -- ROTATION_Y
- gui.animate(node_node1, ROTATION_Y, node_node1_rotation.y + 360, gui.EASING_OUTSINE, 0.6 / speed, 1.5 / speed)
- -- ROTATION_Z
- gui.animate(node_node1, ROTATION_Z, node_node1_rotation.z + 360, gui.EASING_OUTSINE, 0.6 / speed, 2.1 / speed)
- -- SIZE_X
- gui.animate(node_node1, SIZE_X, node_node1_size.x + 58, gui.EASING_OUTSINE, 0.9 / speed)
- -- SIZE_Y
- gui.animate(node_node1, SIZE_Y, node_node1_size.y + 47, gui.EASING_OUTSINE, 0.9 / speed)
- -- Node: node2
- local node_node2 = nodes["node2"]
- local node_node2_color = vmath.vector4(1, 1, 1, 1)
- if not is_relative then
- gui.set_color(node_node2, node_node2_color)
- gui.set_pivot(node_node2, gui.PIVOT_CENTER)
- gui.set_enabled(node_node2, true)
- end
- -- COLOR_X
- gui.animate(node_node2, COLOR_X, node_node2_color.x - 0.02, gui.EASING_OUTSINE, 0.6 / speed, 0 / speed, function()
- gui.animate(node_node2, COLOR_X, node_node2_color.x - 0.16, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node2, COLOR_X, node_node2_color.x, gui.EASING_OUTSINE, 0.4 / speed)
- end)
- end)
- -- COLOR_Y
- gui.animate(node_node2, COLOR_Y, node_node2_color.y - 0.06, gui.EASING_OUTSINE, 0.6 / speed, 0 / speed, function()
- gui.animate(node_node2, COLOR_Y, node_node2_color.y - 0.52, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node2, COLOR_Y, node_node2_color.y, gui.EASING_OUTSINE, 0.4 / speed)
- end)
- end)
- -- COLOR_Z
- gui.animate(node_node2, COLOR_Z, node_node2_color.z - 0.79, gui.EASING_OUTSINE, 0.6 / speed, 0 / speed, function()
- gui.animate(node_node2, COLOR_Z, node_node2_color.z - 0.28, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node2, COLOR_Z, node_node2_color.z, gui.EASING_OUTSINE, 0.4 / speed)
- end)
- end)
- -- TRIGGER_SET_ENABLED
- table.insert(timers, timer.delay(2.1 / speed, false, function()
- gui.set_enabled(node_node2, false)
- end))
- table.insert(timers, timer.delay(2.2 / speed, false, function()
- gui.set_enabled(node_node2, true)
- end))
- table.insert(timers, timer.delay(2.3 / speed, false, function()
- gui.set_enabled(node_node2, false)
- end))
- table.insert(timers, timer.delay(2.4 / speed, false, function()
- gui.set_enabled(node_node2, true)
- end))
- -- TRIGGER_SET_PIVOT
- table.insert(timers, timer.delay(0.4 / speed, false, function()
- gui.set_pivot(node_node2, gui.PIVOT_N)
- end))
- table.insert(timers, timer.delay(0.6 / speed, false, function()
- gui.set_pivot(node_node2, gui.PIVOT_NE)
- end))
- table.insert(timers, timer.delay(0.81 / speed, false, function()
- gui.set_pivot(node_node2, gui.PIVOT_E)
- end))
- table.insert(timers, timer.delay(1 / speed, false, function()
- gui.set_pivot(node_node2, gui.PIVOT_SE)
- end))
- table.insert(timers, timer.delay(1.2 / speed, false, function()
- gui.set_pivot(node_node2, gui.PIVOT_S)
- end))
- table.insert(timers, timer.delay(1.4 / speed, false, function()
- gui.set_pivot(node_node2, gui.PIVOT_SW)
- end))
- table.insert(timers, timer.delay(1.6 / speed, false, function()
- gui.set_pivot(node_node2, gui.PIVOT_W)
- end))
- table.insert(timers, timer.delay(1.8 / speed, false, function()
- gui.set_pivot(node_node2, gui.PIVOT_NW)
- end))
- table.insert(timers, timer.delay(2 / speed, false, function()
- gui.set_pivot(node_node2, gui.PIVOT_CENTER)
- end))
- -- Node: node3
- local node_node3 = nodes["node3"]
- local node_node3_position = vmath.vector3(-200, 250, 0)
- local node_node3_rotation = vmath.vector3(0, 0, 0)
- local node_node3_size = vmath.vector3(97, 91, 0)
- local node_node3_slice9 = vmath.vector4(0, 0, 0, 0)
- if is_relative then
- node_node3_position = gui.get_position(node_node3)
- node_node3_rotation = gui.get_rotation(node_node3)
- node_node3_size = gui.get_size(node_node3)
- else
- gui.set_position(node_node3, node_node3_position)
- gui.set_rotation(node_node3, node_node3_rotation)
- gui.set_size(node_node3, node_node3_size)
- gui.set_slice9(node_node3, node_node3_slice9)
- end
- -- POSITION_X
- gui.animate(node_node3, POSITION_X, node_node3_position.x + 211.17, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node3, POSITION_X, node_node3_position.x - 4.5, gui.EASING_OUTSINE, 0.95 / speed, 0 / speed, function()
- gui.animate(node_node3, POSITION_X, node_node3_position.x, gui.EASING_OUTSINE, 1.04 / speed)
- end)
- end)
- -- POSITION_Y
- gui.animate(node_node3, POSITION_Y, node_node3_position.y + 195.93, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node3, POSITION_Y, node_node3_position.y + 44.57, gui.EASING_OUTSINE, 0.95 / speed, 0 / speed, function()
- gui.animate(node_node3, POSITION_Y, node_node3_position.y, gui.EASING_OUTSINE, 1.04 / speed)
- end)
- end)
- -- ROTATION_Z
- gui.animate(node_node3, ROTATION_Z, node_node3_rotation.z - 45, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node3, ROTATION_Z, node_node3_rotation.z, gui.EASING_OUTSINE, 1.99 / speed)
- end)
- -- SIZE_X
- gui.animate(node_node3, SIZE_X, node_node3_size.x + 97, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node3, SIZE_X, node_node3_size.x, gui.EASING_OUTSINE, 2 / speed)
- end)
- -- SIZE_Y
- gui.animate(node_node3, SIZE_Y, node_node3_size.y + 91, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node3, SIZE_Y, node_node3_size.y, gui.EASING_OUTSINE, 2 / speed)
- end)
- -- SLICE9_W
- gui.animate(node_node3, SLICE9_W, node_node3_slice9.w + 1, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node3, SLICE9_W, node_node3_slice9.w, gui.EASING_OUTSINE, 2 / speed)
- end)
- -- SLICE9_X
- gui.animate(node_node3, SLICE9_X, node_node3_slice9.x + 50, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node3, SLICE9_X, node_node3_slice9.x, gui.EASING_OUTSINE, 2 / speed)
- end)
- -- SLICE9_Y
- gui.animate(node_node3, SLICE9_Y, node_node3_slice9.y + 40, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node3, SLICE9_Y, node_node3_slice9.y, gui.EASING_OUTSINE, 2 / speed)
- end)
- -- SLICE9_Z
- gui.animate(node_node3, SLICE9_Z, node_node3_slice9.z + 5, gui.EASING_OUTSINE, 1 / speed, 0 / speed, function()
- gui.animate(node_node3, SLICE9_Z, node_node3_slice9.z, gui.EASING_OUTSINE, 2 / speed)
- end)
- local counter_timer_id = timer.delay(1 / 60, true, function(_, _, elapsed)
- panthera_animation.current_time = panthera_animation.current_time + elapsed / speed
- end)
- table.insert(timers, counter_timer_id)
- table.insert(timers, timer.delay(panthera_animation.animation_time / speed, false, function()
- if panthera_animation.callback then
- panthera_animation.callback(panthera_animation)
- end
- if panthera_animation.is_loop then
- PantheraAnimation.play(panthera_animation)
- end
- end))
- end
- return PantheraAnimation
Advertisement
Add Comment
Please, Sign In to add comment