-
Notifications
You must be signed in to change notification settings - Fork 28
Change Simple node scripts to instantiate themselves #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@tool | ||
extends SimpleCharacter | ||
|
||
|
||
func _init(): | ||
# Disable the SimpleCharacter _init function. We expect this script is | ||
# already bound to _simple_character.tscn. | ||
pass | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://ddx1cd5q6t61o"] | ||
|
||
[ext_resource type="Script" path="res://addons/block_code/simple_nodes/simple_character/simple_character.gd" id="1_oqwef"] | ||
[ext_resource type="Script" path="res://addons/block_code/simple_nodes/simple_character/_simple_character.gd" id="1_idjqv"] | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_104qs"] | ||
size = Vector2(16, 16) | ||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ffh0f"] | ||
size = Vector2(100, 100) | ||
|
||
[node name="SimpleCharacter" type="CharacterBody2D"] | ||
script = ExtResource("1_oqwef") | ||
script = ExtResource("1_idjqv") | ||
|
||
[node name="Sprite2D" type="Sprite2D" parent="."] | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
shape = SubResource("RectangleShape2D_104qs") | ||
shape = SubResource("RectangleShape2D_ffh0f") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,16 @@ func on_gravity_changed(new_gravity): | |
gravity = new_gravity | ||
|
||
|
||
func _init(): | ||
if self.get_parent(): | ||
return | ||
|
||
var node = preload("res://addons/block_code/simple_nodes/simple_character/_simple_character.tscn").instantiate() as Node | ||
node.replace_by(self, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I play the Pong game, it shows error:
|
||
node.queue_free() | ||
scene_file_path = "" | ||
|
||
|
||
func _ready(): | ||
add_to_group("affected_by_gravity") | ||
simple_setup() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@tool | ||
extends SimpleScoring | ||
|
||
|
||
func _init(): | ||
# Disable the SimpleScoring _init function. We expect this script is | ||
# already bound to _simple_scoring.tscn. | ||
pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,17 @@ const _POSITIONS_FOR_PLAYER = { | |
} | ||
|
||
|
||
func _init(): | ||
if self.get_parent(): | ||
return | ||
|
||
var node = preload("res://addons/block_code/simple_nodes/simple_scoring/_simple_scoring.tscn").instantiate() as Node | ||
node.replace_by(self, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I play the Pong game, it shows error:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh, I see how that happened. That's fixed in the newest set of commits. |
||
node.queue_free() | ||
print_tree_pretty() | ||
scene_file_path = "" | ||
|
||
|
||
func get_custom_class(): | ||
return "SimpleScoring" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍