Skip to content

Commit 8e931a0

Browse files
authored
Fix bug in Chapter2/BGSpriteComponent.cpp
1 parent 22372ca commit 8e931a0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Chapter02/BGSpriteComponent.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ void BGSpriteComponent::Update(float deltaTime)
2121
for (auto& bg : mBGTextures)
2222
{
2323
// Update the x offset
24-
bg.mOffset.x += mScrollSpeed * deltaTime;
24+
bg.mOffset.x -= mScrollSpeed * deltaTime;
2525
// If this is completely off the screen, reset offset to
2626
// the right of the last bg texture
2727
if (bg.mOffset.x < -mScreenSize.x)
2828
{
29-
bg.mOffset.x = (mBGTextures.size() - 1) * mScreenSize.x - 1;
29+
bg.mOffset.x += mScreenSize.x * mBGTextures.size();
3030
}
3131
}
3232
}

0 commit comments

Comments
 (0)