diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2023-12-28 09:41:25 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2023-12-28 09:41:25 +0100 |
commit | 7e579ced0b51f98b2c14a0c868bf428c12d4790b (patch) | |
tree | e9786b6e2e3fe560c648d542a62e5de350f0e3e3 | |
parent | 2a9cbb1fa0268c3be828c0d872180282704abb61 (diff) |
add puppet animation and set transparencyv2.2.1
-rw-r--r-- | Characters/Character.gd | 6 | ||||
-rw-r--r-- | Levels/Level.gd | 8 | ||||
-rw-r--r-- | Network/Network.gd | 2 |
3 files changed, 15 insertions, 1 deletions
diff --git a/Characters/Character.gd b/Characters/Character.gd index ee10c0e..c9eaa0a 100644 --- a/Characters/Character.gd +++ b/Characters/Character.gd @@ -115,6 +115,12 @@ func _physics_process(delta): if Network.player.position != self.position: Network.player.position = self.position Network.update_player() + if Network.player.animation != $Sprite2D.animation: + Network.player.animation = $Sprite2D.animation + Network.update_player() + if Network.player.animation_flip_h != $Sprite2D.flip_h: + Network.player.animation_flip_h = $Sprite2D.flip_h + Network.update_player() func is_running(): diff --git a/Levels/Level.gd b/Levels/Level.gd index 17975ef..40c75ff 100644 --- a/Levels/Level.gd +++ b/Levels/Level.gd @@ -21,8 +21,11 @@ func _ready(): Network.connect("player_changed", func(id): var remote_player = Network.players[id] + var node_name = "%s_%s_%s" % [remote_player.name, remote_player.character, id] - var puppet = self.get_node(node_name) + var puppet = null + if self.has_node(node_name): + puppet = self.get_node(node_name) if remote_player.current_level != self.idx: if puppet: @@ -34,8 +37,11 @@ func _ready(): puppet.process_mode = PROCESS_MODE_DISABLED self.add_child(puppet) puppet.name = node_name + puppet.modulate = Color(1.0, 1.0, 1.0, 0.5) else: puppet.position = remote_player.position + puppet.get_node("Sprite2D").play(remote_player.animation) + puppet.get_node("Sprite2D").flip_h = remote_player.animation_flip_h ) if has_node("ParallaxBackground"): diff --git a/Network/Network.gd b/Network/Network.gd index ce4952c..ac808da 100644 --- a/Network/Network.gd +++ b/Network/Network.gd @@ -29,6 +29,8 @@ func create_player(): components = [], current_level = -1, position = Vector2(0, 0), + animation = "", + animation_flip_h = false, } |