ms.x gives shard
This commit is contained in:
parent
e303d5ac6c
commit
d6e35580fd
2 changed files with 22 additions and 1 deletions
|
@ -2,10 +2,13 @@ extends KinematicBody2D
|
|||
|
||||
var velocity = Vector2.ZERO
|
||||
var is_moving = false
|
||||
var is_holding_shard = true
|
||||
onready var death_particles = $DeathSplatter
|
||||
onready var sprite = $Sprite
|
||||
onready var anims = $AnimationPlayer
|
||||
onready var raycast = $RayCast2D
|
||||
onready var shard_position = $Position2D
|
||||
const shard = preload("res://objects/collectibles/shard.tscn")
|
||||
|
||||
func _ready():
|
||||
raycast.add_exception($Area2D)
|
||||
|
@ -21,6 +24,18 @@ func _physics_process(delta):
|
|||
anims.play("idle")
|
||||
else:
|
||||
anims.play("walk")
|
||||
#Stop at the end of path and give shard
|
||||
if position.x <= 80:
|
||||
Debug.print(Game.shards_collected)
|
||||
is_moving = false
|
||||
velocity.x = 0
|
||||
if is_holding_shard:
|
||||
var ShardInstance = shard.instance()
|
||||
ShardInstance.global_position = Vector2(shard_position.global_position.x,shard_position.global_position.y)
|
||||
ShardInstance.number = 1
|
||||
get_owner().add_child(ShardInstance)
|
||||
is_holding_shard = false
|
||||
|
||||
|
||||
func switch_action():
|
||||
is_moving = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue