Components class
Some class for components
AnimationComponent || AnimationOneTimeComponent
class AnimationComponent {
public:
AnimationComponent(){}
private:
};
class AnimationOneTimeComponent {
public:
AnimationOneTimeComponent(){}
size_t _frame;
};Can be used to animate an entity.
MovableComponent
class MovableComponent {
public:
MovableComponent(){}
private:
};When you add MovableComponent to an entity, it can move. Without this component, your entity cannot move.
ButtonComponent
ButtonComponent is used for example to create a button. As you can see, you can give it a function or an anction to do when he's clicked and that's useful for a button.
ControllableComponent
You will use this class to set your entity position.
The method
ControllableComponent()present in this class will be useful to set which keys you want to control your entity. Ex: For our player, we set key up, key down, key right, key left.The method
getControls()will be useful to get all the keys registered with your entity. Ex: If user press key down, we will be loop on getControls function and check if the key has been pressed (if yes, player will move, otherwise player will not move).The method
getEvent()can be use to get actual events.The method
setEventcan set actuel event into an int.
LoadingBarComponent
LoadingBarComponent is an usefull class to create flexible bar, like a life bar for example.
The method calculate automatically set the width of your bar using its parameter float currentWidth.
MusicComponent
MusicComponent as you may guess, is the component that you will use to handle the music behavior in your game. Its simply an encapsulation of the sfml sf::Music class.
ParallaxComponent
If you want to move an entity from left to the right automatically (like a parallax, ex: game's background) you can use the parallax component. This class needs to the size of your sprite sheet and the speed where it will move.
ParticuleComponent
The ParticuleComponent can be use to create particule with rectangle using sf::IntRect from SFML graphic library.
You can either set the color of the particule and the duration.
PositionComponent
This component can be use to set and get the position of an entity who've this component has been added.
At first, you will use this component to set the position of an entity at the. construction
Secondly, with the methods at your disposition, you will be able to change the current position of your entity (in game) "SET" methods.
Finally, you can get the position of your entity using "GET" methods.
RectangleShapeComponent
RectangleShapeComponent is the component that we use for the player life we can set which Rect that we want depending on the player life. You will find a lot of methods that are useful to handle the display of one of your entities.
ScaleComponent
This component can be use if your entity does'nt fit as you want. Using this component, you can fit your entity as you want.
The first part of this class is useful to set the scale you want for your entity,
The second one will be useful if you want to get the scale set to an entity at his creation.
SoundComponent
SoundComponent is the component that we use for the sound created when the player shoots for example. A sound is different than a music because a sound will be shorter than a music. You will use that if you want a short sonore effect when an action has been done for example.
SpriteComponent
This component is use to store the entity's sprite
If you're using this component, you can:
At first, you will create you sprite from a texture (give details/position)
After that's, you have can set the position of your sprite and set scale for your sprite
However, you can also get the sprite used using the getter method.
TextComponent
TextComponent is the component that you have to use if you wantt to write something on your screen. In this one, you can adjust what you want like position, size, color, content or things like that for your text. You're free to write what you wan and above all how you want.
TextureRectComponent
TextureRect component is useful to set your sprite correctly. To works normally, it needs to get the right informations about the position of your differents things in your sprite's file.
VelocityComponent
This component is very useful to set the velocity to an entity. It works with de MoveComponent component. To works correctly, it needs to get two mains informations : direction &. speed. Once it's setted, your entity will move depending on params you gave.
Last updated