Files
JumpRopeOldTech/slideshower.gd
T
yagigreg ddf7942890
ci/woodpecker/push/woodpecker Pipeline was successful
Rudimentary comic/slideshow viewer and intro scene.
2026-10-18 07:16:08 -05:00

49 lines
1.2 KiB
GDScript

class_name Slideshower
extends Control
signal finished_playing
var slides = []
var slide = 0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func play_slideshow(new_slides) -> void:
slides = new_slides
play_slide(0)
func play_slide(index) -> bool:
if index < 0 or index >= len(slides):
return false
slide = index
var image_path: String = slides[index].image
if not image_path.begins_with("res://"):
image_path = "res://art/slides/%s.png" % image_path
$VSplitContainer/TextFrame/SlideText.text = slides[index].text
$VSplitContainer/ImageFrame/SlideImage.texture = load(image_path)
return true
func next_slide() -> bool:
var success = play_slide(slide + 1)
if not success:
finished_playing.emit()
return success
func prev_slide() -> bool:
return play_slide(slide - 1)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if Input.is_action_just_released("interact") or Input.is_action_just_released("jump") or Input.is_action_just_released("move_right"):
next_slide()
if Input.is_action_just_released("move_left"):
prev_slide()
func _on_continue_button_pressed() -> void:
next_slide()