add animation player to player and add new bnnuy sprites
This commit is contained in:
parent
506394336a
commit
e6026c266f
5 changed files with 488 additions and 48 deletions
|
|
@ -6,18 +6,21 @@ const DEADZONE: float = 0.1
|
|||
@export var max_speed: float = 90
|
||||
|
||||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var anim_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var state_machine: StateMachine = $StateMachine
|
||||
@onready var hit_timer: Timer = $HitTimer
|
||||
|
||||
var anim_dir: String
|
||||
var def_dir: String
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
assert(id == 1 or id == 2, "id ("+str(id)+") is invalid")
|
||||
anim_dir = 'up' if id == 1 else 'down'
|
||||
def_dir = 'up' if id == 1 else 'down'
|
||||
def_dir = 'idle_up' if id == 1 else 'idle_down'
|
||||
hit_timer.connect("timeout", $StateMachine/Hitting._on_hit_end)
|
||||
|
||||
|
||||
func get_movement_vector() -> Vector2:
|
||||
var x_mov: float = Input.get_action_strength('p'+str(id)+'_move_right') - Input.get_action_strength('p'+str(id)+'_move_left')
|
||||
var y_mov: float = Input.get_action_strength('p'+str(id)+'_move_down') - Input.get_action_strength('p'+str(id)+'_move_up')
|
||||
|
|
|
|||
|
|
@ -1,12 +1,381 @@
|
|||
[gd_scene load_steps=21 format=3 uid="uid://642nm6c4mpxx"]
|
||||
[gd_scene load_steps=38 format=3 uid="uid://642nm6c4mpxx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://rdqmsvofiots" path="res://scenes/player/player.gd" id="1_v6fml"]
|
||||
[ext_resource type="Texture2D" uid="uid://b8ptokcqwpdud" path="res://scenes/player/saffron.png" id="2_3li8b"]
|
||||
[ext_resource type="Texture2D" uid="uid://ca744qwgmwejx" path="res://scenes/player/assets/bnuuy-spritesheet.png" id="3_0owmy"]
|
||||
[ext_resource type="Script" uid="uid://dqjaxgmyxq3rx" path="res://scenes/classes/state_machine.gd" id="3_lvxji"]
|
||||
[ext_resource type="Script" uid="uid://delyni51vg6us" path="res://scenes/player/states/idle.gd" id="4_75vfm"]
|
||||
[ext_resource type="Script" uid="uid://dxfs1b8fuk7kv" path="res://scenes/player/states/running.gd" id="5_75vfm"]
|
||||
[ext_resource type="Script" uid="uid://n7v8leojhykt" path="res://scenes/player/states/hitting.gd" id="6_75vfm"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_gx1jg"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [1]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AnimatedSprite2D:animation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [&"idle_up"]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("AnimatedSprite2D:speed_scale")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [1.0]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("AnimatedSprite2D:offset:y")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [-16.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_fm80t"]
|
||||
resource_name = "idle_down"
|
||||
length = 2.0
|
||||
loop_mode = 1
|
||||
step = 0.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:frame")
|
||||
tracks/0/interp = 0
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.6800001, 1.1299999, 1.7200001),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 1]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AnimatedSprite2D:animation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [&"idle_down"]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("AnimatedSprite2D:speed_scale")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_0owmy"]
|
||||
resource_name = "idle_up"
|
||||
length = 2.0
|
||||
loop_mode = 1
|
||||
step = 0.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:frame")
|
||||
tracks/0/interp = 0
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.6800001, 1.1299999, 1.7200001),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 1]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AnimatedSprite2D:animation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [&"idle_up"]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("AnimatedSprite2D:speed_scale")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_qek5x"]
|
||||
resource_name = "walk_right"
|
||||
length = 0.475
|
||||
loop_mode = 1
|
||||
step = 0.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:frame")
|
||||
tracks/0/interp = 0
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.12206663, 0.20329137, 0.37493116),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [1, 0, 1, 2]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AnimatedSprite2D:animation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [&"right"]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("AnimatedSprite2D:speed_scale")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("AnimatedSprite2D:offset:y")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0, 0.12206663, 0.20329137, 0.37493116),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [-16.0, -18.0, -16.0, -18.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_5gtgg"]
|
||||
resource_name = "walk_left"
|
||||
length = 0.475
|
||||
loop_mode = 1
|
||||
step = 0.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:frame")
|
||||
tracks/0/interp = 0
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.12206663, 0.20329137, 0.37493116),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [1, 0, 1, 2]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AnimatedSprite2D:animation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [&"right"]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("AnimatedSprite2D:speed_scale")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("AnimatedSprite2D:offset:y")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0, 0.12206663, 0.20329137, 0.37493116),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [-16.0, -18.0, -16.0, -18.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_h17s1"]
|
||||
resource_name = "hit_left_up"
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:animation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [&"idle_up"]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AnimatedSprite2D:frame")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_je7p5"]
|
||||
resource_name = "hit_right_up"
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:animation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [&"idle_up"]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AnimatedSprite2D:frame")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [2]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ugbui"]
|
||||
resource_name = "hit_right_down"
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:animation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [&"idle_down"]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AnimatedSprite2D:frame")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [2]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_fcs02"]
|
||||
resource_name = "hit_left_down"
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:animation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [&"idle_down"]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AnimatedSprite2D:frame")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ugbui"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_gx1jg"),
|
||||
&"hit_left_down": SubResource("Animation_fcs02"),
|
||||
&"hit_left_up": SubResource("Animation_h17s1"),
|
||||
&"hit_right_down": SubResource("Animation_ugbui"),
|
||||
&"hit_right_up": SubResource("Animation_je7p5"),
|
||||
&"idle_down": SubResource("Animation_fm80t"),
|
||||
&"idle_up": SubResource("Animation_0owmy"),
|
||||
&"walk_left": SubResource("Animation_5gtgg"),
|
||||
&"walk_right": SubResource("Animation_qek5x")
|
||||
}
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_g2els"]
|
||||
atlas = ExtResource("2_3li8b")
|
||||
region = Rect2(0, 64, 24, 32)
|
||||
|
|
@ -19,29 +388,53 @@ region = Rect2(24, 64, 24, 32)
|
|||
atlas = ExtResource("2_3li8b")
|
||||
region = Rect2(48, 64, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qlg0r"]
|
||||
atlas = ExtResource("2_3li8b")
|
||||
region = Rect2(0, 96, 24, 32)
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qek5x"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(96, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
|
||||
atlas = ExtResource("2_3li8b")
|
||||
region = Rect2(24, 96, 24, 32)
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5gtgg"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(128, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fjrip"]
|
||||
atlas = ExtResource("2_3li8b")
|
||||
region = Rect2(48, 96, 24, 32)
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_h17s1"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(160, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_smehm"]
|
||||
atlas = ExtResource("2_3li8b")
|
||||
region = Rect2(0, 32, 24, 32)
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_0owmy"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(192, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ur7pv"]
|
||||
atlas = ExtResource("2_3li8b")
|
||||
region = Rect2(24, 32, 24, 32)
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_je7p5"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(224, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_y4r1p"]
|
||||
atlas = ExtResource("2_3li8b")
|
||||
region = Rect2(48, 32, 24, 32)
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fm80t"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(256, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_myrg7"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(0, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kvlxm"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(32, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uf5tr"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(64, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gx1jg"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(0, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ugbui"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(32, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fcs02"]
|
||||
atlas = ExtResource("3_0owmy")
|
||||
region = Rect2(64, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_d2wvv"]
|
||||
atlas = ExtResource("2_3li8b")
|
||||
|
|
@ -76,16 +469,41 @@ animations = [{
|
|||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qlg0r")
|
||||
"texture": SubResource("AtlasTexture_qek5x")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tuyoq")
|
||||
"texture": SubResource("AtlasTexture_5gtgg")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fjrip")
|
||||
"texture": SubResource("AtlasTexture_h17s1")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle_down",
|
||||
"speed": 0.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_0owmy")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tuyoq")
|
||||
"texture": SubResource("AtlasTexture_je7p5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fm80t")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle_up",
|
||||
"speed": 0.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_myrg7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kvlxm")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_uf5tr")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"left",
|
||||
|
|
@ -93,20 +511,17 @@ animations = [{
|
|||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_smehm")
|
||||
"texture": SubResource("AtlasTexture_gx1jg")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ur7pv")
|
||||
"texture": SubResource("AtlasTexture_ugbui")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_y4r1p")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ur7pv")
|
||||
"texture": SubResource("AtlasTexture_fcs02")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"right",
|
||||
"speed": 5.0
|
||||
"speed": 0.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
|
|
@ -126,9 +541,8 @@ animations = [{
|
|||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_oprun"]
|
||||
radius = 5.0
|
||||
height = 16.0
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_0owmy"]
|
||||
radius = 8.0
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
collision_layer = 2
|
||||
|
|
@ -136,15 +550,20 @@ collision_mask = 13
|
|||
floor_stop_on_slope = false
|
||||
script = ExtResource("1_v6fml")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_ugbui")
|
||||
}
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_f1ej7")
|
||||
animation = &"down"
|
||||
frame_progress = 0.29168898
|
||||
animation = &"idle_up"
|
||||
offset = Vector2(0, -16)
|
||||
flip_h = true
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, -8)
|
||||
shape = SubResource("CapsuleShape2D_oprun")
|
||||
position = Vector2(-1, -8)
|
||||
shape = SubResource("CircleShape2D_0owmy")
|
||||
|
||||
[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("initial_state")]
|
||||
script = ExtResource("3_lvxji")
|
||||
|
|
|
|||
|
|
@ -19,9 +19,18 @@ func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
|||
previous_state_path = _previous_state_path
|
||||
hit_dir = _data.get("hit_dir")
|
||||
|
||||
player.sprite.play('up' if player.id == 1 else 'down')
|
||||
player.sprite.frame = 1
|
||||
player.sprite.pause()
|
||||
#player.sprite.play('up' if player.id == 1 else 'down')
|
||||
#player.sprite.frame = 1
|
||||
#player.sprite.pause()
|
||||
|
||||
player.anim_player.play("hit_"+hit_dir+"_up" if player.id == 1 else "hit_"+hit_dir+"_down")
|
||||
assert(
|
||||
player.anim_player.current_animation == "hit_left_up" or
|
||||
player.anim_player.current_animation == "hit_left_down" or
|
||||
player.anim_player.current_animation == "hit_right_up" or
|
||||
player.anim_player.current_animation == "hit_right_down",
|
||||
"invalid animation ("+player.anim_player.current_animation+")"
|
||||
)
|
||||
|
||||
var sprite_texture: Texture2D = player.sprite.sprite_frames.get_frame_texture('up', 1)
|
||||
var hit_node: Area2D = preload("res://scenes/hit/hit.tscn").instantiate()
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
|||
player.velocity = Vector2.ZERO
|
||||
player.move_and_slide()
|
||||
|
||||
player.sprite.play(player.def_dir)
|
||||
player.sprite.frame = 1
|
||||
player.sprite.pause()
|
||||
#player.sprite.play(player.def_dir)
|
||||
#player.sprite.frame = 1
|
||||
#player.sprite.pause()
|
||||
|
||||
player.anim_player.play(player.def_dir)
|
||||
|
||||
print("entered")
|
||||
|
||||
|
|
|
|||
|
|
@ -24,12 +24,19 @@ func _state_physics_update(_delta: float) -> void:
|
|||
return
|
||||
|
||||
if abs(player.velocity.x) > abs(player.velocity.y):
|
||||
player.anim_dir = 'right' if player.velocity.x > 0 else 'left'
|
||||
if player.velocity.x > 0:
|
||||
if player.anim_player.current_animation != "walk_right": player.anim_player.play("walk_right")
|
||||
player.sprite.flip_h = false
|
||||
else:
|
||||
player.anim_dir = 'down' if player.velocity.y > 0 else 'up'
|
||||
if player.anim_player.current_animation != "walk_left": player.anim_player.play("walk_left")
|
||||
player.sprite.flip_h = true
|
||||
else:
|
||||
pass
|
||||
#player.anim_dir = 'down' if player.velocity.y > 0 else 'up'
|
||||
|
||||
player.sprite.play(player.anim_dir)
|
||||
#player.sprite.play(player.anim_dir)
|
||||
|
||||
func _exit() -> void:
|
||||
player.sprite.stop()
|
||||
player.anim_player.stop()
|
||||
player.sprite.flip_h = false
|
||||
print("exit")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue