gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > sprite problem

#5150 - blaow - Tue Apr 22, 2003 7:54 am

ok i have a class sprite that has the attributes activeFrame and spriteFrame(an array), these attributes are used for Sprite animation purpose. when i use them like this:
(lets say we pointing the attributes to a sprite with 2 frames)
spriteName.activeFrame = 0;
spriteName.spriteFrame[0]=0;
spriteName.spriteFrame[1]=8;

it works perfectly fine... however when i try to do this
(same thing but in a function in a different class so it can do this process for n sprites)

void setFrame(Sprite name, int numberFrames){
int c2=0;
for(int c=0; c<numberFrames; c++){
name.spriteFrame[c] = c2;
c2=c2+8;
}

my code compiles fine but when the sprite shows it is not animated.. it stays in its activeFrame all the way.. any clues people?
many thanks
_________________
blaow~~

#5153 - delbogun - Tue Apr 22, 2003 8:45 am

probably because it animates too fast. create a delay before changing frame.

#5181 - Saj - Tue Apr 22, 2003 7:35 pm

I had a similar problem once.
I think you need to check where you are updating OAM (attribute 2).

Check GBA Junkie's tutorial on sprite animation :-

http://www.mdh165.pwp.blueyonder.co.uk/docstuts/Chapter4_SpritesDisplayandAnimation.pdf

also

Quote:
delbogun : probably because it animates too fast.


You'll notice a flicker on the screen if this is the case. (I could be wrong on that though but I've never seen it animate so fast that it doesn't cause a flicker)

Hope this helps...
_________________
---------------------------------------------------
Click here to give free food to starving animals.
--------------------------------------------------

#5207 - blaow - Wed Apr 23, 2003 6:58 am

got it to work.. it wasnt any of the above.. just some minor thing.. thanks anyways
_________________
blaow~~