I am following tutorials outlined in "SFML Game Development" by Packt Publishing. In chapter 4, I am having many errors, most notably " missing type specifier - int assumed. Note: C++ does not support default-int". Here is my header and source file that this is referring to:
#pragma once
#include <assert.h>
#include <algorithm>
#include <vector>
#include <SFML\Graphics.hpp>
#include "Category.h"
#include "Command.h"
class SceneNode : public sf::Transformable, public sf::Drawable, private sf::NonCopyable
{
public:
typedef std::unique_ptr<SceneNode> Ptr;
public:
SceneNode();
void attachChild(Ptr);
Ptr detachChild(const SceneNode&);
void update(sf::Time);
sf::Transform getWorldTransform() const;
sf::Vector2f getWorldPosition() const;
unsigned int getCategory() const;
void onCommand(const Command&, sf::Time);
private:
virtual void draw(sf::RenderTarget&, sf::RenderStates) const;
virtual void drawCurrent(sf::RenderTarget&, sf::RenderStates) const;
virtual void updateCurrent(sf::Time);
void updateChildren(sf::Time);
private:
std::vector<Ptr> mChildren;
SceneNode* mParent;
};
#include "SceneNode.h"
SceneNode::SceneNode() : mChildren(), mParent(nullptr)
{
}
void SceneNode::attachChild(Ptr child)
{
child->mParent = this;
mChildren.push_back(std::move(child));
}
SceneNode::Ptr SceneNode::detachChild(const SceneNode& node)
{
auto found = std::find_if(mChildren.begin(), mChildren.end(), [&] (Ptr& p) -> bool
{
return p.get() == &node;
});
assert(found != mChildren.end());
Ptr result = std::move(*found);
result->mParent = nullptr;
mChildren.erase(found);
return result;
}
void SceneNode::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
drawCurrent(target, states);
for(auto itr = mChildren.begin(); itr != mChildren.end(); ++itr)
{
(*itr)->draw(target, states);
}
}
void SceneNode::drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const
{
}
void SceneNode::updateCurrent(sf::Time dt)
{
}
void SceneNode::update(sf::Time dt)
{
updateCurrent(dt);
updateChildren(dt);
}
void SceneNode::updateChildren(sf::Time dt)
{
for(auto itr = mChildren.begin(); itr != mChildren.end(); ++itr)
{
(*itr)->update(dt);
}
}
sf::Transform SceneNode::getWorldTransform() const
{
sf::Transform transform = sf::Transform::Identity;
for(const SceneNode* node = this; node != nullptr; node = node->mParent)
{
transform = node->getTransform() * transform;
}
return transform;
}
sf::Vector2f SceneNode::getWorldPosition() const
{
return getWorldTransform() * sf::Vector2f();
}
unsigned int SceneNode::getCategory() const
{
return Category::Scene;
}
void SceneNode::onCommand(const Command& command, sf::Time dt)
{
if(command.category & getCategory())
{
command.action(*this, dt);
for(auto itr = mChildren.begin(); itr != mChildren.end(); ++itr)
{
(*itr)->onCommand(command, dt);
}
}
}
The error is specifically on line 23:
void onCommand(const Command&, sf::Time);
Any ideas?