简体   繁体   English

由于未知原因,SFML Sprite不显示

[英]SFML Sprite not displaying for unknown reasons

I do not know why but my sprite is not displaying. 我不知道为什么,但是我的精灵没有显示。 When i run the code i get no errors and i did a cout and it appears the function which calls setTextureRect on the sprite is getting called. 当我运行代码时,我没有收到任何错误,并且执行了提示操作,并且似乎调用了在sprite上调用setTextureRect的函数。

this is the call to the function the this pointer in this case refers to an Instance of the Player object 这是对该函数的调用,在这种情况下,此指针指向Player对象的实例

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

this is the function itself, Frame is just a typedef for sf::IntRect 这就是函数本身,Frame只是sf :: IntRect的typedef

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

In the game loop i called 在游戏循环中,我打电话给

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

I think you have the white square problem. 我认为您有白方块问题。 http://www.sfml-dev.org/tutorials/2.3/graphics-sprite.php is where you can find a solution(you might not though). http://www.sfml-dev.org/tutorials/2.3/graphics-sprite.php是您可以找到解决方案的地方(您可能没有找到)。 This also happened to me, although I still have the problem. 尽管我仍然遇到问题,但这也发生在我身上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM