fix errorspew in movesideside enemies without an AnimatedSprite (fixes #88)
This commit is contained in:
parent
28920ef700
commit
0655605091
7 changed files with 13 additions and 10 deletions
|
@ -11,10 +11,10 @@ export var direction = 1
|
|||
export var speed = 50
|
||||
#Move horizontal or vertical
|
||||
export(Direction) var move_direction
|
||||
export var flip_sprite = true
|
||||
export var node_to_flip: NodePath
|
||||
#Onreadys
|
||||
onready var startpos = position
|
||||
onready var sprite = $AnimatedSprite
|
||||
onready var _flipped_node: Node2D = get_node_or_null(node_to_flip)
|
||||
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
|
@ -40,10 +40,12 @@ func move_side_to_side(delta):
|
|||
#Switch dir
|
||||
if position.x >= startpos.x + (right_down_boundary):
|
||||
direction = -1
|
||||
if flip_sprite == true: sprite.scale.x = -1
|
||||
if is_instance_valid(_flipped_node):
|
||||
_flipped_node.scale.x = -1.0
|
||||
if position.x <= startpos.x + (-left_up_boundary):
|
||||
direction = 1
|
||||
if flip_sprite == true: sprite.scale.x = 1
|
||||
if is_instance_valid(_flipped_node):
|
||||
_flipped_node.scale.x = 1.0
|
||||
|
||||
func move_up_and_down(delta):
|
||||
#Move
|
||||
|
@ -51,10 +53,12 @@ func move_up_and_down(delta):
|
|||
#Switch dir
|
||||
if position.y >= startpos.y + (right_down_boundary):
|
||||
direction = -1
|
||||
if flip_sprite == true: sprite.scale.y = 1
|
||||
if is_instance_valid(_flipped_node):
|
||||
_flipped_node.scale.y = 1.0
|
||||
if position.y <= startpos.y + (-left_up_boundary):
|
||||
direction = 1
|
||||
if flip_sprite == true: sprite.scale.y = -1
|
||||
if is_instance_valid(_flipped_node):
|
||||
_flipped_node.scale.y = -1.0
|
||||
|
||||
# editor debug drawing
|
||||
func _draw():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue