我正在尝试使用SDL(C++)为一张图片(320宽度,64高度)生成一个动画,每帧的长度为64×64。动画在SDL(C++)中不正确?
我的问题是,我的整个图片(320×64)挤在64×64的空间,而不是每帧显示。
我有一个与方法绘制()
AnimatedSprite::Draw(BackBuffer& backbuffer)
{
//set frame width
this->SetFrameWidth(64);
//set x coordinate
this->SetX(frameCoordinateContainer[m_currentFrame-1]);
backbuffer.DrawAnimatedSprite(*this);
}
方法DrawAnimatedSprite是这样的绘制动画的AnimatedSprite类,
void BackBuffer::DrawAnimatedSprite(AnimatedSprite& animatedSprite)
{
SDL_Rect fillRect;
fillRect.x = animatedSprite.GetX();
fillRect.y = animatedSprite.GetY();
fillRect.w = animatedSprite.getFrameWidth();
fillRect.h = animatedSprite.GetHeight();
SDL_RenderCopy(m_pRenderer, animatedSprite.GetTexture()->GetTexture(), 0, &fillRect);
}
所以任何人有任何想法,可能是错的? 谢谢!
对不起,我不太明白,那我该如何改进呢? @LogicStuff – Wilheim
尝试用'&fillRect'交换'0'。 – LogicStuff
我用'&fillRect'交换'0',但那里没有任何东西。 @LogicStuff – Wilheim