create red turtle behavior logic

This commit is contained in:
Chris Cromer 2022-11-21 02:15:09 -03:00
parent 9adf496504
commit bb6550851a
2 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,19 @@
using Godot;
using System;
public class RedTurtle : EnemyWalking
{
private AnimatedSprite _sprite;
public override void _Ready()
{
base._Ready();
_sprite = GetNode<AnimatedSprite>("AnimatedSprite");
_sprite.Play("walk");
}
public void OnVisibilityNotifier2DScreenExited()
{
Reset();
}
}

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://assets/turtle/red_walking.png" type="Texture" id=1] [ext_resource path="res://assets/turtle/red_walking.png" type="Texture" id=1]
[ext_resource path="res://assets/turtle/red_shell.png" type="Texture" id=2] [ext_resource path="res://assets/turtle/red_shell.png" type="Texture" id=2]
[ext_resource path="res://scenes/enemies/turtle/red/RedTurtle.cs" type="Script" id=3]
[sub_resource type="AtlasTexture" id=8] [sub_resource type="AtlasTexture" id=8]
atlas = ExtResource( 2 ) atlas = ExtResource( 2 )
@ -39,6 +40,7 @@ extents = Vector2( 9.5, 8 )
extents = Vector2( 5.5, 6 ) extents = Vector2( 5.5, 6 )
[node name="RedTurtle" type="KinematicBody2D"] [node name="RedTurtle" type="KinematicBody2D"]
script = ExtResource( 3 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."] [node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 4 ) frames = SubResource( 4 )
@ -54,3 +56,9 @@ visible = false
position = Vector2( -0.5, 2 ) position = Vector2( -0.5, 2 )
shape = SubResource( 7 ) shape = SubResource( 7 )
disabled = true disabled = true
[node name="VisibilityEnabler2D" type="VisibilityEnabler2D" parent="."]
process_parent = true
physics_process_parent = true
[connection signal="screen_exited" from="VisibilityEnabler2D" to="." method="OnVisibilityNotifier2DScreenExited"]