Coin state machines archives created but not functional

This commit is contained in:
Martin Araneda 2022-05-24 23:17:16 -04:00
parent a079d8aa37
commit 20e2fafcf4
5 changed files with 116 additions and 5 deletions

View File

@ -1,7 +1,6 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://assets/coin.png" type="Texture" id=1]
[ext_resource path="res://Collectables/Coin/Coin.gd" type="Script" id=2]
[sub_resource type="CircleShape2D" id=1]
radius = 6.0
@ -24,7 +23,6 @@ animations = [ {
[node name="coin" type="Area2D"]
collision_layer = 4
script = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 9, 9 )
@ -35,5 +33,3 @@ frames = SubResource( 4 )
frame = 1
playing = true
centered = false
[connection signal="body_entered" from="." to="." method="_on_coin_body_entered"]

View File

0
src/Coin/CoinCollected.h Normal file
View File

View File

@ -0,0 +1,39 @@
#include "player/states/CoinNotCollected.h"
using namespace godot;
void CoinNotCollected::_register_methods()
{
register_method("_state_enter", &CoinNotCollected::_state_enter);
register_method("_state_exit", &CoinNotCollected::_state_exit);
register_method("_physics_process", &CoinNotCollected::_physics_process);
}
CoinNotCollected::CoinNotCollected()
{
}
CoinNotCollected::~CoinNotCollected()
{
}
void CoinNotCollected::_init()
{
}
void CoinNotCollected::_state_enter()
{
animated_sprite = get_parent()->get_node<AnimatedSprite>("AnimatedSprite");
animated_sprite->stop();
animated_sprite->set_animation("idle");
}
void CoinNotCollected::_state_exit()
{
}
void CoinNotCollected::_physics_process(float delta)
{
}

View File

@ -0,0 +1,76 @@
#ifndef JUEGO_COIN_COINNOTCOLLECTED
#define JJUEGO_COIN_COINNOTCOLLECTED
#include "state_machine/State.h"
#include <Godot.hpp>
#include <Node.hpp>
#include <AnimatedSprite.hpp>
namespace godot
{
/**
* @brief This class controls what happens when the Coin is in the not collected state.
*
*/
class CoinNotCollected : public State
{
GODOT_CLASS(CoinNotCollected, State)
private:
/**
* @brief The animated sprite of the Coin.
*
*/
AnimatedSprite *animated_sprite;
public:
/**
* @brief This method registers classes with Godot.
*
* @details This method registers methods, properties, and signals with the Godot engine.
*/
static void _register_methods();
/**
* @brief Construct a new CoinNotCollected object.
*
*/
CoinNotCollected();
/**
* @brief Destroy the CoinNotCollected object.
*
*/
~CoinNotCollected();
/**
* @brief Initialize the class from Godot.
*
* @details This method is called just once when the Godot engine connects to the instance of the class.
*/
void _init();
/**
* @brief Called when the not collected state of the coin is entered.
*
*/
void _state_enter();
/**
* @brief Called when the not collected state of the coin is exited.
*
*/
void _state_exit();
/**
* @brief The physics processed every delta time.
*
* @param[in] delta The time since the method was last run.
*/
void _physics_process(float delta);
};
}
#endif