Skip to content

Instantly share code, notes, and snippets.

@LarsBergqvist
Created February 16, 2018 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LarsBergqvist/36b1f53b0501b2aa07b6ecab65f2c7fa to your computer and use it in GitHub Desktop.
Save LarsBergqvist/36b1f53b0501b2aa07b6ecab65f2c7fa to your computer and use it in GitHub Desktop.
Godot: star spawning and re-routing the star_taken signal to the main scene
extends Node2D
export (PackedScene) var Star
signal star_was_taken
export (int) var total_stars = 0
export (int) var stars_found = 0
func _ready():
var pos_curve = $ItemPositions.get_curve()
total_stars = pos_curve.get_point_count()
for i in range(0, total_stars):
var star = Star.instance()
add_child(star)
star.position = pos_curve.get_point_position(i)
star.connect("star_taken", self, "on_star_taken")
func on_star_taken():
stars_found += 1
emit_signal("star_was_taken")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment