#6694 - einhaender - Mon Jun 02, 2003 1:27 am
Hi, iam new to gba coding and i started playing a bit with tutorial source codes from thepernproject.com. I created me a 32x32 pixel sprite with 4 frames of animation. Now I wanted to switch to the next frame every 2 seconds without any user input. However after waiting an initial first second my animation starts playing rapidly und uncontrolled and I guess it might have something to do with the while loop. Anyone can propose a better solution?
Heres the code snippet iam using in my main():
while(1) {
Wait(1);
switchFrame();
WaitForVsync();
CopyOAM();
}
And my switchFrame() looks like this:
void switchFrame() {
Sprite.activeFrame = Sprite.activeFrame == 3 ? 0 : Sprite.activeFrame += 1;
sprites[0].attribute2 = Sprite.spriteFrame[Sprite.activeFrame];
}
Heres the code snippet iam using in my main():
while(1) {
Wait(1);
switchFrame();
WaitForVsync();
CopyOAM();
}
And my switchFrame() looks like this:
void switchFrame() {
Sprite.activeFrame = Sprite.activeFrame == 3 ? 0 : Sprite.activeFrame += 1;
sprites[0].attribute2 = Sprite.spriteFrame[Sprite.activeFrame];
}