Skip to content

Instantly share code, notes, and snippets.

@Razzlegames
Last active August 29, 2015 14:17
Show Gist options
  • Save Razzlegames/969a241f46b1345fa9f8 to your computer and use it in GitHub Desktop.
Save Razzlegames/969a241f46b1345fa9f8 to your computer and use it in GitHub Desktop.
extends Node2D
var rock_points = 0
var rock_res = preload("res://rock.scn")
var time_passed = 0
# Used only to create a unique rock name
var rock_count = 0
func _ready():
#set_process(true)
var rock_instance = rock_res.instance()
# Now each rock instance will have a unique name (IMPORTANT!!!)
rock_instance.set_name("new_rock_instance"+ str(rock_count))
print("New rock name: "+ rock_instance.get_name())
add_child(rock_instance)
rock_instance.set_owner(self)
rock_count +=1
if rock_instance.get_owner() == null:
print(str(rock_instance.get_name()) + ": I still have no owner!\n")
else:
print(str(rock_instance.get_name()) + ": My owner is " + \
str(rock_instance.get_owner().get_name()) + "\n")
print("-- Thanks for your help! --")
# Uncomment to see many instances being made
#func _process(delta):
# time_passed += delta
# if(time_passed < 1):
# return
#
# var rock_instance = rock_res.instance()
# rock_instance.set_name("new_rock_instance"+ str(rock_count))
# print("New rock name: "+ rock_instance.get_name())
# add_child(rock_instance)
# rock_instance.set_owner(self)
# if rock_instance.get_owner() == null:
# print(str(rock_instance.get_name()) + ": I still have no owner!\n")
# else:
# print(str(rock_instance.get_name()) + ": My owner is " + \
# str(rock_instance.get_owner().get_name()) + "\n")
# # You cannot do this, since get_owner on this top level node will return null always!
# #print(str(rock_instance.get_name()) + ": My owner is " + str(get_owner().get_name()) + "\n")
# rock_count +=1
# pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment