Hello,
I have an Entity class like that :
#ifndef Entity_hpp
#define Entity_hpp
#include <vector>
#include <cmath>
#include <iostream>
#include <SFML/Graphics.hpp>
class Entity
{
public:
Entity(int width, int height);
void update();
void setDimension(int width, int height);
void setDimension(sf::Vector2i dim);
const sf::Vector2i getDimension() { return sf::Vector2i(mSpriteWidth, mSpriteHeight); };
sf::Sprite getSprite() { return mSprite; };
sf::ConvexShape getConvex() { return mConvex; };
void setPosition(sf::Vector2f position) { mPosition = position; };
sf::Vector2f getPosition() { return mPosition; };
private:
sf::Sprite mSprite;
sf::ConvexShape mConvex;
int mSpriteWidth = 50;
int mSpriteHeight = 50;
sf::Vector2f mPosition;
};
#endif /* Entity_hpp */
My issue:
If in a class that inherit from my Entity class, I want to get my convex shape (or mSprite) with getConvex() (or getSprite()) it's doesn't showing anything... but if I put these variables from private to protected and I use them directly it's working perfectly, and I don't know why, someone could explain to me?
Thanks
I have an IsoTile class like that :
#ifndef IsoTile_hpp
#define IsoTile_hpp
#include "Entity.hpp"
class IsoTile: public Entity
{
private:
sf::VertexArray mLine;
float mThickness = 0;
sf::Vector2f mPositionInWindow;
sf::Vector2f mScale;
public:
IsoTile(int tileWidth, int tileHeight, int thickness);
const sf::Vector2f getPositionInWindow() { return mPositionInWindow; };
const sf::Vector2f getTileScale() { return mScale; };
void setPositionInWindow(float x, float y);
void setPositionInWindow(sf::Vector2f &position);
void setTexturePosition(int x, int y);
void setDimension(int width, int height, int thickness);
void setDimension(sf::Vector2i dim, int thickness);
float getThickness() { return mThickness; };
};
#endif /* IsoTile_hpp */
And the constructor :
IsoTile::IsoTile(int tileWidth, int tileHeight, int thickness) : Entity(tileWidth, tileHeight)
{
setDimension(tileWidth, tileHeight, thickness);
getConvex().setFillColor(sf::Color::White);
mScale.x = 1;
mScale.y = 1;
}
The setFillColor here doesn't working...