Skip to reading
Eight Adventure Interface Workshops

Play an Image sequence once

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

Record ID: one_shot. Global Script: off. Create animation_lab with the Image anim_arrow and four distinct frame IDs at 6 FPS, as in Chapter 3. Show that GUI before running this example.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var values: Dictionary = Runtime.get("variables")
    if bool(values.get("ui_busy", false)):
        return false
    var manager: Node = Runtime.get("authored_gui_manager")
    var nodes: Dictionary = manager.get("element_nodes")
    var host: Control = nodes.get("anim_arrow") as Control
    if not is_instance_valid(host):
        return false
    var image: PCAGUISpritePlayer = host.get_node_or_null("GUIContentImage")
    if not is_instance_valid(image):
        return false
    await SetVariable({"name":"ui_busy", "value":true})
    image.loop_animation = false
    image.restart()
    await get_tree().create_timer(4.0 / 6.0).timeout
    if is_instance_valid(image):
        image.playing = false
    await SetVariable({"name":"ui_busy", "value":false})
    return true

The script restarts the native Image player, disables looping and holds the last frame. Adapt the element ID and the duration together when using a chest-lid or page-turn drawing.

The example uses a four-frame, 6-FPS schedule. If you change the frame count or rate, change the wait as well. Keep live inventory/save widgets separate from the moving drawing.

Page 106 of 119Permalink
Go to page