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

2012/4/28

Tiled Files

Denzien Denzien

2012/4/28

#
I just want to know, is it possible to create animation from one file with the animation sprites tiled together, and use code to specify picking only a certain area in a file? If so, can someone tell me how.
danpost danpost

2012/4/28

#
You would be better off reading the whole file in at start-up (or during object creation) and reading the images into an array of GreenfootImages; and then use something like the AnimatedActor class to control the image rotation. Two advantages are that you only read in the file one time (before action, instead of during action which may cause some lag time) and the images can be controlled by an integer using
setImage(images[++imageNumber % totalNumberOfImages]);
Denzien Denzien

2012/4/28

#
The only reason I want to do this is remove the high number of picture files in my Images folder, but it doesn't really bother me that much except for organisation, and lag isn't really what I really want, so I think I will just leave it as it is.
You need to login to post a reply.