piggy fixies! :)
This commit is contained in:
parent
0c9528c7c1
commit
9a5d19789c
3 changed files with 16 additions and 5 deletions
Binary file not shown.
Before Width: | Height: | Size: 455 B After Width: | Height: | Size: 4.3 KiB |
|
@ -5,7 +5,7 @@ export var walk_speed = 25.0
|
|||
export var left_boundary = 0.0 setget _set_left_boundary
|
||||
export var right_boundary = 0.0 setget _set_right_boundary
|
||||
export var direction = 1.0
|
||||
export var idle_turns = 4
|
||||
export var idle_turns = 0
|
||||
export var turn_time = 0.5
|
||||
export var shoot_time = 1.0
|
||||
|
||||
|
@ -76,12 +76,23 @@ func _do_turn():
|
|||
get_tree().create_timer(turn_time, false).connect("timeout", self, "_do_turn")
|
||||
return
|
||||
sprite.play("idle")
|
||||
# still pause with zero "turns"
|
||||
if idle_turns <= 0:
|
||||
# set turns to -1 to stop walking
|
||||
turns = -1
|
||||
# wait for turn_tie
|
||||
yield(get_tree().create_timer(turn_time, false), "timeout")
|
||||
sprite.scale.x *= -1.0
|
||||
# wait a bit after turning
|
||||
get_tree().create_timer(turn_time, false).connect("timeout", self, "set", ["turns", 0])
|
||||
return
|
||||
sprite.scale.x *= -1.0
|
||||
if turns < idle_turns * 2:
|
||||
turns += 1
|
||||
get_tree().create_timer(turn_time, false).connect("timeout", self, "_do_turn")
|
||||
else:
|
||||
turns = 0
|
||||
get_tree().create_timer(turn_time, false).connect("timeout", self, "set", ["turns", 0])
|
||||
# turns = 0
|
||||
|
||||
func _stop_shoot():
|
||||
shooting = false
|
||||
|
@ -95,7 +106,7 @@ func _stop_shoot():
|
|||
func _draw():
|
||||
if Engine.editor_hint:
|
||||
var left = -left_boundary * 8.0
|
||||
var right = right_boundary * 8.0
|
||||
var right = right_boundary * 8.0 + 8.0
|
||||
draw_line(
|
||||
Vector2(left, 0.0),
|
||||
Vector2(right, 0.0),
|
||||
|
|
|
@ -62,13 +62,13 @@ colors = PoolColorArray( 1, 1, 1, 1, 1, 1, 0.290196, 1 )
|
|||
|
||||
[node name="Cop" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
idle_turns = 2
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
show_behind_parent = true
|
||||
material = SubResource( 7 )
|
||||
position = Vector2( 5, -2 )
|
||||
frames = SubResource( 6 )
|
||||
animation = "shoot"
|
||||
animation = "idle"
|
||||
playing = true
|
||||
|
||||
[node name="ShootPosition" type="Position2D" parent="AnimatedSprite"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue