在SFML中缺少sf :: Vector2类模板

时间:2012-11-28 09:00:24

标签: c++ macos g++ sfml

我一直在浏览http://www.sfml-dev.org/tutorials/1.6/的教程,我在using views tutorial遇到了问题。

以下是我正在处理的代码部分:

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main(){

    // Create instance of Window
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

    sf::Vector2 Center(1000, 1000);
    sf::Vector2 HalfSize(400, 300);
    sf::View View1(Center, HalfSize);

    // So on...

我使用的是Mac OSX 10.8,我正在使用g ++进行编译。我收到错误消息:

error: missing template arguments before ‘Center’

如何更正此错误?

编辑:我以某种方式阅读了错误的教程。想成为Vector2f。

2 个答案:

答案 0 :(得分:2)

您的问题正如错误所述,您错过了Vector2模板的类型,并通过View类的构造函数进行判断,

View (const sf::Vector2f &Center, const sf::Vector2f &HalfSize)

你想要一个Vector2<float>。这些类型在typedef

中已为您Vector2.hpp dd
// Define the most common types
typedef Vector2<int>          Vector2i;
typedef Vector2<unsigned int> Vector2u;
typedef Vector2<float>        Vector2f;

答案 1 :(得分:1)

指定矢量的类型,例如sf::Vector2<int>