2022-06-11 00:26:11 -04:00
|
|
|
#include "coin/CoinNotCollected.h"
|
2022-05-24 23:17:16 -04:00
|
|
|
|
2022-08-28 01:08:04 -04:00
|
|
|
#include <Area2D.hpp>
|
2022-07-15 23:04:06 -04:00
|
|
|
|
2022-08-28 01:08:04 -04:00
|
|
|
void alai::CoinNotCollected::_register_methods()
|
2022-05-24 23:17:16 -04:00
|
|
|
{
|
2022-08-31 00:36:01 -04:00
|
|
|
godot::register_method("_state_enter", &CoinNotCollected::_state_enter);
|
|
|
|
godot::register_method("_state_exit", &CoinNotCollected::_state_exit);
|
|
|
|
godot::register_method("_on_body_entered", &CoinNotCollected::_on_body_entered);
|
2022-05-24 23:17:16 -04:00
|
|
|
}
|
|
|
|
|
2022-08-28 01:08:04 -04:00
|
|
|
alai::CoinNotCollected::CoinNotCollected()
|
2022-05-24 23:17:16 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-08-28 01:08:04 -04:00
|
|
|
alai::CoinNotCollected::~CoinNotCollected()
|
2022-05-24 23:17:16 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-08-28 01:08:04 -04:00
|
|
|
void alai::CoinNotCollected::_init()
|
2022-05-24 23:17:16 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-08-28 01:08:04 -04:00
|
|
|
void alai::CoinNotCollected::_state_enter()
|
2022-05-24 23:17:16 -04:00
|
|
|
{
|
2022-08-28 01:08:04 -04:00
|
|
|
animated_sprite = get_parent()->get_node<godot::AnimatedSprite>("AnimatedSprite");
|
2022-06-06 20:59:51 -04:00
|
|
|
animated_sprite->set_animation("spin");
|
|
|
|
animated_sprite->play();
|
2022-05-24 23:17:16 -04:00
|
|
|
}
|
|
|
|
|
2022-08-28 01:08:04 -04:00
|
|
|
void alai::CoinNotCollected::_state_exit()
|
2022-05-24 23:17:16 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-08-28 01:08:04 -04:00
|
|
|
void alai::CoinNotCollected::_on_body_entered(Node *node)
|
2022-05-24 23:17:16 -04:00
|
|
|
{
|
2022-06-11 00:26:11 -04:00
|
|
|
auto parent_node = get_parent();
|
|
|
|
|
|
|
|
if (parent_node != nullptr)
|
|
|
|
{
|
2022-08-28 01:08:04 -04:00
|
|
|
auto coin = Object::cast_to<godot::Area2D>(parent_node);
|
2022-06-11 00:26:11 -04:00
|
|
|
coin->set_collision_mask_bit(0, false);
|
|
|
|
}
|
2022-07-15 23:04:06 -04:00
|
|
|
|
2022-06-11 00:26:11 -04:00
|
|
|
get_state_machine()->change("CoinCollected");
|
2022-05-24 23:17:16 -04:00
|
|
|
}
|