【发布时间】: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();
【问题讨论】: