feature/Coin #32
@ -82,4 +82,4 @@ margin_right = 256.0
|
||||
margin_bottom = 32.0
|
||||
text = "##"
|
||||
|
||||
[connection signal="ready" from="CoinHUD/Coins" to="Player" method="_on_CoinHUD_ready"]
|
||||
[connection signal="ready" from="CoinHUD" to="Player" method="_on_CoinHUD_ready"]
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <AnimationPlayer.hpp>
|
||||
|
||||
using namespace godot;
|
||||
int coin = 0;
|
||||
|
||||
void CoinCollected::_register_methods()
|
||||
{
|
||||
@ -25,7 +26,7 @@ void CoinCollected::_init()
|
||||
|
||||
void CoinCollected::_state_enter()
|
||||
{
|
||||
|
||||
coin = coin + 1;
|
||||
auto node = get_parent()->find_node("AnimationPlayer");
|
||||
|
||||
if (node != nullptr)
|
||||
@ -33,6 +34,7 @@ void CoinCollected::_state_enter()
|
||||
auto animation_player = Object::cast_to<AnimationPlayer>(node);
|
||||
animation_player->play("jump");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CoinCollected::_state_exit()
|
||||
@ -44,6 +46,8 @@ void CoinCollected::_on_animation_finished(String anim_name)
|
||||
{
|
||||
this->get_parent()->queue_free();
|
||||
|
||||
// get_state_machine()->change("CoinCounter");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using namespace godot;
|
||||
|
||||
|
||||
void CoinCounter::_register_methods()
|
||||
{
|
||||
register_method("_state_enter", &CoinCounter::_state_enter);
|
||||
@ -35,6 +36,8 @@ void CoinCounter::_state_exit()
|
||||
|
||||
void CoinCounter::_on_CoinHUD_ready()
|
||||
{
|
||||
|
||||
get_node("Coins").text() = "hola";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using namespace godot;
|
||||
|
||||
|
||||
void CoinNotCollected::_register_methods()
|
||||
{
|
||||
register_method("_state_enter", &CoinNotCollected::_state_enter);
|
||||
@ -45,6 +46,7 @@ void CoinNotCollected::_on_body_entered(Node *node)
|
||||
auto coin = Object::cast_to<Area2D>(parent_node);
|
||||
coin->set_collision_mask_bit(0, false);
|
||||
}
|
||||
|
||||
get_state_machine()->change("CoinCollected");
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user