Browse Source

added animation to enemy soldier

galo 1 year ago
parent
commit
3b745fcbc2
3 changed files with 4 additions and 16 deletions
  1. 1 0
      Enemy.gd
  2. 1 14
      enemiessprite.gd
  3. 2 2
      main.tscn

+ 1 - 0
Enemy.gd

@@ -21,6 +21,7 @@ export var tickrate = 4
 
 func _physics_process(delta):
 	tick += 1
+	type = 0 if motion.x == 0 else 1
 	if fmod(tick,tickrate) == 0:
 		if target == null: _ready()
 		if target == null: return

+ 1 - 14
enemiessprite.gd

@@ -4,20 +4,7 @@ var sprite = preload('res://enemie/monster.tscn')
 
 func _ready():
 	for i in 1024:
-		var add= sprite.instance()
-#		add.texture = load('res://icon.png')
+		var add = sprite.instance()
 		add.z_index = 1
 		add_child(add)
-#		add= sprite.instance()
-#		add.texture = get_node('../../Textures').dict['Goblin2']
-#		add.z_index = 2
-#		add_child(add)
-#		add= sprite.instance()
-#		add.texture = get_node('../../Textures').dict['Goblin3']
-#		add.z_index = 3
-#		add_child(add)
-#		add= sprite.instance()
-#		add.texture = get_node('../../Textures').dict['Goblin4']
-#		add.z_index = 4
-#		add_child(add)
 	pass # Replace with function body.

+ 2 - 2
main.tscn

@@ -126,7 +126,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin3"]
 modulate = Color( 1, 0, 0, 1 )
 frames = SubResource( 5 )
-frame = 3
+frame = 2
 speed_scale = 1.2
 playing = true
 offset = Vector2( 32, 32 )
@@ -140,7 +140,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin4"]
 modulate = Color( 1, 0, 0.984314, 1 )
 frames = SubResource( 5 )
-frame = 1
+frame = 3
 speed_scale = 0.9
 playing = true
 offset = Vector2( 32, 32 )