【问题标题】:SFML Sprite not displaying for unknown reasonsSFML Sprite 因未知原因未显示
【发布时间】:2016-07-15 06:46:42
【问题描述】:

我不知道为什么,但我的精灵没有显示。当我运行代码时,我没有收到任何错误,并且我做了一个 cout,它似乎调用了在 sprite 上调用 setTextureRect 的函数。

this 是对函数的调用,在这种情况下,this 指针指向 Player 对象的一个​​实例

anim.playFrame(this, sf::IntRect(32, 0, 32, 32));

这是函数本身,Frame 只是 sf::IntRect 的 typedef

void Animation::playFrame(IAnimatable* entity, Frame frame) {
    entity->sprite.setTextureRect(frame);
    std::cout << "new texture set" << std::endl;
}

在我调用的游戏循环中

Window.draw(player.sprite);
Window.display();

【问题讨论】:

    标签: c++ sfml


    【解决方案1】:

    我认为你有白色方块问题。 http://www.sfml-dev.org/tutorials/2.3/graphics-sprite.php 是您可以找到解决方案的地方(但您可能不会)。这也发生在我身上,虽然我仍然有问题。

    【讨论】:

    • mhm 我无法确定这是否是我的问题的根源,但我可以将 VS 解决方案发送给您吗?这是一个非常简单的程序。
    猜你喜欢
    • 1970-01-01
    • 2016-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-25
    • 1970-01-01
    相关资源
    最近更新 更多