akien-mga / dynadungeons

Bomberman clone using Godot Engine - Not actively developed since 2015.
GNU General Public License v3.0
216 stars 36 forks source link

World Sub-Scene References #21

Open ghost opened 9 years ago

ghost commented 9 years ago

One thing I was hoping to do (but had trouble with) was put references to sub-scenes of World in global.gd. For example:

global.gd var level = get_tree().get_root().get_node("World/Level")

level.gd var level = get_node("/root/global").level

The problem is that because global.gd is instantiated before the scene tree, global.gd can't find the tree and so it throws a fit.

Any ideas for the best way to implement these references? Perhaps it would be easiest to create a script for World and store them in there.

akien-mga commented 9 years ago

Yeah currently I'm referencing the level scene for everything that can't be done via global.gd, e.g.:

func _ready():
    global = get_node("/root/global")
    level = get_node("/root").get_node("Level")

I guess you could add a script for the world yes, and move part of the level variables in there.

akien-mga commented 9 years ago

Off-topic, but if you like hanging around on IRC, you'll find me idling on Freenode's #kobuge channel together with the other Godot and FLOSS aficionados of @KOBUGE-Games :)

ghost commented 9 years ago

Good stuff! Thanks for that :)

Will jump in to that some time.