forked from team-sg/hero-mark-2
add jumping spider
This commit is contained in:
parent
3e5f3a67b9
commit
e0c4bf6077
6 changed files with 195 additions and 17 deletions
33
objects/enemy/enemy_jump.gd
Normal file
33
objects/enemy/enemy_jump.gd
Normal file
|
@ -0,0 +1,33 @@
|
|||
extends "res://objects/enemy/enemy.gd"
|
||||
|
||||
export var left_boundary = 0
|
||||
export var right_boundary = 0
|
||||
export var speed = 50
|
||||
export var flip_sprite = true
|
||||
export var direction = 1
|
||||
onready var startpos = position
|
||||
|
||||
onready var anims = $AnimationPlayer
|
||||
onready var sprite = $Sprite
|
||||
|
||||
func _ready():
|
||||
anims.play("idle")
|
||||
|
||||
func _physics_process(delta):
|
||||
if anims.current_animation == "jump":
|
||||
#Move
|
||||
position.x += direction * (speed * delta)
|
||||
#Switch dir
|
||||
if position.x >= startpos.x + (right_boundary * 8):
|
||||
direction = -1
|
||||
if flip_sprite == true: sprite.scale.x = -1
|
||||
if position.x <= startpos.x + (-left_boundary * 8):
|
||||
direction = 1
|
||||
if flip_sprite == true: sprite.scale.x = 1
|
||||
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||
if anim_name == "idle":
|
||||
anims.play("jump")
|
||||
else:
|
||||
anims.play("idle")
|
Loading…
Add table
Add a link
Reference in a new issue