SFML community forums

Help => General => Topic started by: twiggystardust on September 23, 2013, 08:11:07 am

Title: Help with SFML Game Development book
Post by: twiggystardust on September 23, 2013, 08:11:07 am
Hello, I have recently started building the project in the book and I have made it to chapter 3. But I have a problem, I was presented with this error

sfmlapplication\aircraft.cpp(22): error C2027: use of undefined type 'ResourceHolder<Resource,Identifier>'
1>          with
1>          [
1>              Resource=sf::Texture,
1>              Identifier=Textures::ID
1>          ]

So I go take a look at where the error is, the code looks like:

20  Aircraft::Aircraft(Type type, const TextureHolder& textures)
21  : mType(type)
22  , mSprite(textures.get(toTextureID(type)))
23  {
24        sf::FloatRect bounds = mSprite.getLocalBounds();
25        mSprite.setOrigin(bounds.width / 2.f, bounds.height /2.f);
26  }

It seems that there is a problem with
mSprite(textures.get(toTextureID(type)))
and when I hover over textures with the mouse it pops up with "Error: incomplete type is not allowed" I have no idea why this would be, because as far as I can tell, other than the statistic stuff, my code is Identical to the code that was e-mailed to me. Also I did not include the string helper files, are those even needed? They aren't mentioned in the book so I figured they were for the statistics. Can anyone please help? I can't find any problems.
Title: Re: Help with SFML Game Development book
Post by: Nexus on September 23, 2013, 09:45:04 am
It looks like an #include <Book/ResourceHolder.hpp> directive is missing.

In any case, can you try the newer code version from GitHub (https://github.com/SFML/SFML-Game-Development-Book)? Please follow the ReadMe file step by step carefully, in order to set everything up correctly.

Title: Re: Help with SFML Game Development book
Post by: twiggystardust on September 24, 2013, 07:04:29 am
Hello Nexus and thank you for you quick reply. I checked the code and you are correct. I did not include ResourceHolder.h. I had accidentally included the ResourceIdentifier.h and while I was comparing code, I must not have looked at that part close enough. Thank you very much again.