This site requires JavaScript, please enable it in your browser!
Greenfoot back
nungzabza1916
nungzabza1916 wrote ...

2014/4/2

about animation

nungzabza1916 nungzabza1916

2014/4/2

#
How I make animation that run from first frame to last frame by use Only one input(keyboard or mouse click)
danpost danpost

2014/4/2

#
Put in act method or in a method it calls (possibly called 'runAnimation'):
if (frame > 0)
{
    setImage("imageName"+frame+".png");
    if (frame++ == maxFrames) frame = 0;
}
Then just set 'frame' equal to one on keyboard or mouse action.
if (Greenfoot.mouseClicked(null)) frame = 1;
'frame' and 'maxFrames' should be declared as instance fields and 'maxFrames' should be initialized to the appropriate value.
nungzabza1916 nungzabza1916

2014/4/2

#
Thank you danpost. ^^
You need to login to post a reply.