1
General / Code of sfml book?
« on: October 11, 2014, 03:25:43 pm »
Code of sfml book and the actual tutorial is different?
Im on chapter and i got one error where VS can is saying the my TextureHolder is undefined. I cant figure out how to solve it. I declare all the header on my aircraft.h
But when i look on the code of sfml book there is this ResourceIdentifiers. Its not event mentioned in the book
Here is my whole code
This is the code im following on the book. But i dont know why the "this_undefined" variable is undefined in my IDE
NOTE: I change it to the word "this_undefined" to highlight the error
Im on chapter and i got one error where VS can is saying the my TextureHolder is undefined. I cant figure out how to solve it. I declare all the header on my aircraft.h
But when i look on the code of sfml book there is this ResourceIdentifiers. Its not event mentioned in the book
Here is my whole code
#include "Entity.h"
#include "ResourceHolder.h"
class Aircraft : public Entity
{
public:
enum class Type{
Eagle,
Raptor
};
Aircraft(Type type, const this_undefined& textures); <--------- this is the error; its undefined
virtual void drawCurrent(sf::RenderTarget &target, sf::RenderStates states) const;
private:
Type mType;
sf::Sprite mSprite;
};
#include "ResourceHolder.h"
class Aircraft : public Entity
{
public:
enum class Type{
Eagle,
Raptor
};
Aircraft(Type type, const this_undefined& textures); <--------- this is the error; its undefined
virtual void drawCurrent(sf::RenderTarget &target, sf::RenderStates states) const;
private:
Type mType;
sf::Sprite mSprite;
};
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include<assert.h>
#include<map>
#include <iostream>
#include <memory>
using namespace std;
namespace Textures{
enum class Type{
Eagle,
Raptor
};
}
template<typename Resource, typename Identifier>
class ResourceHolder{
public:
void load(Identifier id, const std::string &filename);
template<typename Parameter>
void load(Identifier id, const std::string &filename, const Parameter &secondParam);
Resource &get(Identifier id);
const Resource &get(Identifier id) const;
typedef ResourceHolder<sf::Texture, Textures::Type> this_undenfined;
private:
std::map<Identifier, std::unique_ptr<Resource>> mResourceMap;
};
#include <SFML/System.hpp>
#include<assert.h>
#include<map>
#include <iostream>
#include <memory>
using namespace std;
namespace Textures{
enum class Type{
Eagle,
Raptor
};
}
template<typename Resource, typename Identifier>
class ResourceHolder{
public:
void load(Identifier id, const std::string &filename);
template<typename Parameter>
void load(Identifier id, const std::string &filename, const Parameter &secondParam);
Resource &get(Identifier id);
const Resource &get(Identifier id) const;
typedef ResourceHolder<sf::Texture, Textures::Type> this_undenfined;
private:
std::map<Identifier, std::unique_ptr<Resource>> mResourceMap;
};
This is the code im following on the book. But i dont know why the "this_undefined" variable is undefined in my IDE
NOTE: I change it to the word "this_undefined" to highlight the error