create goomba behavior

This commit is contained in:
2022-11-21 00:42:55 -03:00
parent a567b0c3a3
commit 6ffb2a58d0
4 changed files with 83 additions and 3 deletions

View File

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

View File

@@ -1,6 +1,7 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/goomba/walking.png" type="Texture" id=1]
[ext_resource path="res://scenes/enemies/goomba/Goomba.cs" type="Script" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
@@ -23,10 +24,11 @@ animations = [ {
} ]
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 6.5, 7 )
extents = Vector2( 6.67969, 7 )
[node name="Goomba" type="KinematicBody2D" groups=["Enemy", "Stompable"]]
collision_layer = 4
script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 4 )
@@ -34,5 +36,14 @@ animation = "walk"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
position = Vector2( 0.5, 2 )
position = Vector2( 0.320312, 2 )
shape = SubResource( 5 )
[node name="VisibilityEnabler2D" type="VisibilityEnabler2D" parent="."]
visible = false
position = Vector2( 1, 0 )
rect = Rect2( -9, -9, 18, 18 )
process_parent = true
physics_process_parent = true
[connection signal="screen_exited" from="VisibilityEnabler2D" to="." method="OnVisibilityNotifier2DScreenExited"]