minor changes

This commit is contained in:
Martin Araneda 2022-07-15 23:04:06 -04:00
parent 3a58777773
commit b25e1f040c
4 changed files with 12 additions and 3 deletions

View File

@ -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"]

View File

@ -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");
}

View File

@ -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";
}

View File

@ -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");