【问题标题】:Missing sf::Vector2 class template in SFMLSFML 中缺少 sf::Vector2 类模板
【发布时间】:2012-11-16 01:56:47
【问题描述】:

我一直在阅读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。

【问题讨论】:

    标签: c++ macos g++ sfml


    【解决方案1】:

    您的问题与错误所说的完全一样,您缺少Vector2 模板的类型,并通过View 类的构造函数判断,

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

    你想要一个Vector2&lt;float&gt;。这些类型已在Vector2.hpp 中为您提供typedef'd

    // Define the most common types
    typedef Vector2<int>          Vector2i;
    typedef Vector2<unsigned int> Vector2u;
    typedef Vector2<float>        Vector2f;
    

    【讨论】:

      【解决方案2】:

      指定向量的类型,如sf::Vector2&lt;int&gt;

      【讨论】:

      • 虽然这在技术上是正确的,但您应该使用 SFML 提供的 typedef(其他人所述的 sf::Vector2f)。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-26
      • 2012-05-09
      • 2012-04-18
      相关资源
      最近更新 更多