我正在嘗試使用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