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

2013/9/1

How to use spritesheets for animations?

K_wow K_wow

2013/9/1

#
I've noticed that a lot of games using moving sprites have all the animation frames in one image. Is it possible to animate an object this way in greenfoot, or is it more trouble than it's worth?
danpost danpost

2013/9/1

#
Greenfoot does not work with the spritesheets as a whole. You have to split the sheet into its individual images for Greenfoot to use them. Therefore, it is up to you whether or not to use a spritesheet or just give names to your images the represent the order of use (for example: 'image1.png', 'image2.png', 'image3.png', etc.) that can be easily retrieved by building the string name ("image"+imageNumber+".png"). As an alternative, create an array of the images and use the array's index to get the appropriate image from the imageNumber value. Another alternative, is using the GIFActor super(support)class that is available on the site.
K_wow K_wow

2013/9/1

#
Ok, thanks for explaining it to me. I guess I'll just keep doing it the way I was, a bunch of separate images named according to the motion. Thanks again!
You need to login to post a reply.