summaryrefslogtreecommitdiff
path: root/scenes/defenders/base_animation_handler.gd
blob: c9e76303f4317fc6a65cf806c2fbf295c82277f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
extends Sprite2D

@onready var tile_map = preload("res://assets/tilemap.png")

var idle : Rect2
var attack : Rect2
var is_idle : bool = true

func _ready():
	update_texture()

func update_texture():
	var atlas_texture = AtlasTexture.new()
	atlas_texture.atlas = tile_map
	atlas_texture.region = idle if is_idle else attack
	texture = atlas_texture

func attack_state():
	is_idle = false
	update_texture()

func idle_state():
	is_idle = true
	update_texture()