create player state class
This commit is contained in:
parent
13ae274106
commit
37d5fa981d
4 changed files with 40 additions and 1 deletions
32
scenes/classes/player_state.gd
Normal file
32
scenes/classes/player_state.gd
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
class_name PlayerState extends State
|
||||
|
||||
const IDLE = "Idle"
|
||||
const RUNNING = "Running"
|
||||
const HITTING = "Hitting"
|
||||
|
||||
var player: Player
|
||||
|
||||
func _ready() -> void:
|
||||
await owner.ready
|
||||
player = owner as Player
|
||||
assert(player != null, "The PlayerState state type must be used only in the player scene. It needs the owner to be a Player node.")
|
||||
|
||||
|
||||
func enter(previous_state_path: String, data: Dictionary = {}) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func exit() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func handle_input(_event: InputEvent) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func state_update(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func state_physics_update(_delta: float) -> void:
|
||||
pass
|
||||
1
scenes/classes/player_state.gd.uid
Normal file
1
scenes/classes/player_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b2sr7p80gdjii
|
||||
6
scenes/classes/player_state.tscn
Normal file
6
scenes/classes/player_state.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://delu380dsl2kl"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b2sr7p80gdjii" path="res://scenes/classes/player_state.gd" id="1_opnr7"]
|
||||
|
||||
[node name="PlayerState" type="Node"]
|
||||
script = ExtResource("1_opnr7")
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
extends CharacterBody2D
|
||||
class_name Player extends CharacterBody2D
|
||||
|
||||
@export var id: int = 1
|
||||
@export var max_speed: float = 90
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue