From 95e87fd140fbf89ecedc2b535f08dcc3f553569f Mon Sep 17 00:00:00 2001 From: "DavidCrompton1192@gmail.com" Date: Sat, 3 Jun 2023 16:31:51 -0400 Subject: [PATCH] Basic Throw Animation tied to Flick Input --- player.gd | 15 +++++++++++++-- player.tscn | 19 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/player.gd b/player.gd index ec975bb..9945e0a 100644 --- a/player.gd +++ b/player.gd @@ -36,6 +36,17 @@ func _input(event): "player_right", "player_up", "player_down" - ) - + ) set_move_direction(direction) + + var flick = Input.get_vector( + "flick_left", + "flick_right", + "flick_up", + "flick_down" + ) + + if flick.length_squared() != 0: + $PlayerSprite.play("throw") + else: + $PlayerSprite.play("still") diff --git a/player.tscn b/player.tscn index 2e0c8f9..a15059a 100644 --- a/player.tscn +++ b/player.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=8 format=3 uid="uid://btlutggxxokno"] +[gd_scene load_steps=10 format=3 uid="uid://btlutggxxokno"] [ext_resource type="Script" path="res://player.gd" id="1_8jh48"] [ext_resource type="Texture2D" uid="uid://yfxicvvu3j1k" path="res://art/player/Player1.png" id="1_wikqw"] [ext_resource type="Texture2D" uid="uid://ctik1n8vyproe" path="res://art/player/Player2.png" id="2_31x2h"] [ext_resource type="Texture2D" uid="uid://c5jkrxnrk8s4y" path="res://art/player/Player3.png" id="3_xoeqj"] [ext_resource type="Texture2D" uid="uid://bxg6vu3byvcfa" path="res://art/player/Player4.png" id="4_08rsg"] +[ext_resource type="Texture2D" uid="uid://dfia7yrc5ds2w" path="res://art/player/throw/PlayerThrow1.png" id="6_yjoir"] +[ext_resource type="Texture2D" uid="uid://isrtm6ip2y5a" path="res://art/player/throw/PlayerThrow2.png" id="7_qb6xx"] [sub_resource type="SpriteFrames" id="SpriteFrames_obpd0"] animations = [{ @@ -24,6 +26,17 @@ animations = [{ "loop": true, "name": &"still", "speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("6_yjoir") +}, { +"duration": 1.0, +"texture": ExtResource("7_qb6xx") +}], +"loop": true, +"name": &"throw", +"speed": 5.0 }] [sub_resource type="RectangleShape2D" id="RectangleShape2D_m60wa"] @@ -37,9 +50,7 @@ texture_filter = 1 position = Vector2(0, -24) scale = Vector2(2, 2) sprite_frames = SubResource("SpriteFrames_obpd0") -animation = &"still" -frame = 1 -frame_progress = 0.999076 +animation = &"throw" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, -23)