This site requires JavaScript, please enable it in your browser!
Greenfoot back
chavi.malhotra@gmail.com
chavi.malhotra@gmail.com wrote ...

2014/3/24

Explosion images

Hi. I have a list of images which I would like to use to create an explosion. The image is at http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/explosion_alpha.png I would like to create an explosion using these 24 images starting from the first and ending in the last. I am not able to understand how can I be able to do this in Greenfoot. Is there any function where we could cut the image and then draw them one after the other. The size of each image in this list of images is 128*128
danpost danpost

2014/3/24

#
Maybe you could use the 'GifActor' class which uses a gif image to animate an actor. You can find and download it by clicking on 'Documents' above and going to the bottom of the Documents page to find the link to support classes. Oh, it is also part of the support classes that are downloaded when you download greenfoot. Use the menubar and select 'Edit>Import class...', select the class and click the 'Import' button.
Thanks for the reply. I have imported the class but it needs a gif file. Also, do we need to have numbered frames of images for the same? Could you briefly tell what this support class is doing and if I can use it with the image I have.
danpost danpost

2014/3/25

#
chavi.malhotra@gmail.com wrote...
Thanks for the reply. I have imported the class but it needs a gif file. Also, do we need to have numbered frames of images for the same? Could you briefly tell what this support class is doing and if I can use it with the image I have.
I have not worked with that class personally; but, from looking at it, is accepts other types of files other than ".gif" files. Maybe It would be better if you created some simple (well, more simple than the GifActor class) method to break the image file up into its individual images yourself. Since you already know the size of each image it should not be too hard to do.
danpost danpost

2014/3/25

#
(1) create a GreenfootImage object from the file (2) create an array to hold the individual images (3) iterate across the image create GreenfootImage objects of frame size and draw the file image onto them using negative frame sized offsets and add them to the array (4) add a timer and a frame number field to your actor class to control which image will be displayed when
You need to login to post a reply.