refonte de l'inspecteur #61
This commit is contained in:
@@ -2,7 +2,7 @@ extends CharacterBody2D
|
||||
class_name Player
|
||||
|
||||
const MAX_REACH = 100
|
||||
const HOLDING_ITEM_SPRITE_SIZE = 40.
|
||||
const HOLDING_ITEM_SPRITE_SIZE = 20.
|
||||
|
||||
signal player_updated(player: Player)
|
||||
signal upgraded
|
||||
@@ -75,6 +75,7 @@ func _on_inventory_updated(_inventory: Inventory):
|
||||
1./(item_texture.get_width()/HOLDING_ITEM_SPRITE_SIZE),
|
||||
1./(item_texture.get_height()/HOLDING_ITEM_SPRITE_SIZE)
|
||||
)
|
||||
%HideEyes.visible = inventory.get_item() != null
|
||||
%ItemSprite.visible = inventory.get_item() != null
|
||||
emit_signal("player_updated", self)
|
||||
|
||||
@@ -90,9 +91,14 @@ func calculate_direction():
|
||||
|
||||
velocity = input_direction * speed
|
||||
if input_direction.x:
|
||||
$Sprite.flip_h = (input_direction.x < 0)
|
||||
flip_character(input_direction.x > 0)
|
||||
|
||||
|
||||
func flip_character(face_right = true):
|
||||
$Sprite.flip_h = not face_right
|
||||
%ItemSprite.position.x = abs(%ItemSprite.position.x) * (1 if face_right else -1)
|
||||
%HideEyes.position.x = abs(%ItemSprite.position.x) * (1 if face_right else -1)
|
||||
|
||||
func can_interact(interactable : Interactable):
|
||||
return interactable.can_interact(self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user