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

2019/2/7

GIF not working on site

valdes valdes

2019/2/7

#
For greenfoot site administrators: I have games that are using the GIFImage import class. The games work fine on Greenfoot, but when they are uploaded to this site, they crash. I am using the latest version of that class, in Greenfoot 3.5.3. Is there are trick for using GIFs on the site? I give links to games with that problem: game1 game2 This guy discussed the same problem: game3
nccb nccb

2019/2/7

#
GIFImage uses an API to load files from disk. This is not currently supported in the online version. (GreenfootImage is a special case that is overridden to load files from the uploaded JAR). It would be nice to support this, but unfortunately we don't currently have plans to add this functionality. The only hack I can think of right now to support GIFs is if you turned the GIF into a Java file containing the file content as an array, then modified GIFImage to allow passing in an array of data rather than a file name. This may not be impossible for some of the more advanced Java programmers among you. You'd be looking to turn a GIF into:
public class GIFData
{
    public static final byte data = new byte[] {23, 46, 1, ...};
}
Where 23 is the first byte of the GIF file, 46 is the second byte and so on. You'd then need to use the GifDecoder read method that takes an InputStream, passing a ByteArrayInputStream that wraps the GIFData.data byte array.
You need to login to post a reply.