Simple animation in Java... help from gurus?

Discussion in 'OT Technology' started by Auream, Apr 13, 2004.

  1. Auream

    Auream New Member

    Joined:
    Sep 24, 2002
    Messages:
    276
    Likes Received:
    0
    Location:
    Syracuse, NY
    I am part of a group developing a simple Java game for a University course. I want to add some simple animation, the type that one would normally see in an animated GIF file. In fact, being able to directly use an animated GIF would be perfect.

    I tried creating a JPanel (within a JFrame) that contained an "Image" that I set to an animated gif file. This worked perfectly on my Mac at home, but on the XP machines at school, the JFrame runs and is just empty (not even the first frame is shown).

    The animation has a fairly large 640 x 480 background, but there is relatively little actual motion, so the animated gif is fairly small (280K for 7 seconds or so). I know that I could make a whole bunch of individual frames, and iterate through an array to display them and everything, but this would mean I wouldn't easily be able to take advantage of the interframe compression inherent in animated gifs (seeing as though the background doesn't really change). Thus the file size would be at least 10x higher and performance wouldn't be as good.

    Does anyone know a way to properly use animated GIFs in a Java application? Or a better way to show individual frames? I also considered using the Java Media Framework and just playing an actual movie file, but the "user" shouldn't have to download any additional libraries or anything to run the program.
     
  2. Auream

    Auream New Member

    Joined:
    Sep 24, 2002
    Messages:
    276
    Likes Received:
    0
    Location:
    Syracuse, NY
    Anyone have any ideas? I can post the code I already have if you need it.
     

Share This Page