some gd script testing
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -90,9 +90,10 @@ height = 54.0
|
|||||||
|
|
||||||
[node name="player" type="CharacterBody2D"]
|
[node name="player" type="CharacterBody2D"]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
|
collision_layer = 5
|
||||||
|
collision_mask = 5
|
||||||
motion_mode = 1
|
motion_mode = 1
|
||||||
script = ExtResource("1_qehox")
|
script = ExtResource("1_qehox")
|
||||||
metadata/_edit_lock_ = true
|
|
||||||
|
|
||||||
[node name="rotation_center" type="Marker2D" parent="."]
|
[node name="rotation_center" type="Marker2D" parent="."]
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
@@ -109,7 +110,6 @@ metadata/_edit_lock_ = true
|
|||||||
[node name="animated_sprite_2d" type="AnimatedSprite2D" parent="."]
|
[node name="animated_sprite_2d" type="AnimatedSprite2D" parent="."]
|
||||||
sprite_frames = SubResource("SpriteFrames_65gi3")
|
sprite_frames = SubResource("SpriteFrames_65gi3")
|
||||||
animation = &"move_down"
|
animation = &"move_down"
|
||||||
metadata/_edit_lock_ = true
|
|
||||||
|
|
||||||
[node name="main_cam" type="Camera2D" parent="."]
|
[node name="main_cam" type="Camera2D" parent="."]
|
||||||
process_callback = 0
|
process_callback = 0
|
||||||
@@ -130,6 +130,6 @@ metadata/_edit_lock_ = true
|
|||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
[node name="collision_shape" type="CollisionShape2D" parent="."]
|
[node name="collision_shape" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2(0, 37)
|
position = Vector2(0, 36)
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
shape = SubResource("CapsuleShape2D_38v5o")
|
shape = SubResource("CapsuleShape2D_38v5o")
|
||||||
|
@@ -2,6 +2,29 @@
|
|||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://ca1es3hoj53wg" path="res://assets/textures/enemies/slime_green_atlas.png" id="1_bw6us"]
|
[ext_resource type="Texture2D" uid="uid://ca1es3hoj53wg" path="res://assets/textures/enemies/slime_green_atlas.png" id="1_bw6us"]
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id="GDScript_78jn1"]
|
||||||
|
resource_name = "debug"
|
||||||
|
script/source = "extends CharacterBody2D
|
||||||
|
|
||||||
|
var speed = 35
|
||||||
|
var motion = Vector2.ZERO
|
||||||
|
|
||||||
|
var player = null
|
||||||
|
|
||||||
|
func _physics_process(_delta):
|
||||||
|
motion = Vector2.ZERO
|
||||||
|
if player:
|
||||||
|
motion = position.direction_to(player.position) * speed
|
||||||
|
velocity = motion
|
||||||
|
move_and_slide()
|
||||||
|
|
||||||
|
func OnArea2dBodyEntered(body):
|
||||||
|
player = body
|
||||||
|
|
||||||
|
func OnArea2dBodyExited(_body):
|
||||||
|
player = null
|
||||||
|
"
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_eghup"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_eghup"]
|
||||||
atlas = ExtResource("1_bw6us")
|
atlas = ExtResource("1_bw6us")
|
||||||
region = Rect2(0, 0, 64, 64)
|
region = Rect2(0, 0, 64, 64)
|
||||||
@@ -34,28 +57,20 @@ animations = [{
|
|||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}]
|
}]
|
||||||
|
|
||||||
[sub_resource type="GDScript" id="GDScript_6slvi"]
|
|
||||||
resource_name = "animation"
|
|
||||||
script/source = "extends AnimatedSprite2D
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
play()
|
|
||||||
"
|
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_e6mi3"]
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_e6mi3"]
|
||||||
radius = 6.0
|
radius = 6.0
|
||||||
height = 56.0
|
height = 56.0
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_3gptu"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_3gptu"]
|
||||||
radius = 211.464
|
radius = 440.41
|
||||||
|
|
||||||
[node name="slime" type="CharacterBody2D"]
|
[node name="slime" type="CharacterBody2D"]
|
||||||
|
script = SubResource("GDScript_78jn1")
|
||||||
|
|
||||||
[node name="animated_sprite_2d" type="AnimatedSprite2D" parent="."]
|
[node name="animated_sprite_2d" type="AnimatedSprite2D" parent="."]
|
||||||
position = Vector2(0, 33)
|
position = Vector2(0, 33)
|
||||||
sprite_frames = SubResource("SpriteFrames_bwr2v")
|
sprite_frames = SubResource("SpriteFrames_bwr2v")
|
||||||
frame_progress = 0.491853
|
frame_progress = 0.348187
|
||||||
script = SubResource("GDScript_6slvi")
|
|
||||||
|
|
||||||
[node name="collision_shape_2d" type="CollisionShape2D" parent="."]
|
[node name="collision_shape_2d" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2(1, 43)
|
position = Vector2(1, 43)
|
||||||
@@ -63,6 +78,12 @@ rotation = 1.5708
|
|||||||
shape = SubResource("CapsuleShape2D_e6mi3")
|
shape = SubResource("CapsuleShape2D_e6mi3")
|
||||||
|
|
||||||
[node name="area_2d" type="Area2D" parent="."]
|
[node name="area_2d" type="Area2D" parent="."]
|
||||||
|
position = Vector2(0, 32)
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 4
|
||||||
|
|
||||||
[node name="collision_shape_2d" type="CollisionShape2D" parent="area_2d"]
|
[node name="collision_shape_2d" type="CollisionShape2D" parent="area_2d"]
|
||||||
shape = SubResource("CircleShape2D_3gptu")
|
shape = SubResource("CircleShape2D_3gptu")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="area_2d" to="." method="OnArea2dBodyEntered"]
|
||||||
|
[connection signal="body_exited" from="area_2d" to="." method="OnArea2dBodyExited"]
|
||||||
|
Reference in New Issue
Block a user