JBurst is a non-revolutionary addition to Java Swing modeled from HaxeFlixel that adds sprites with animation and simple transformation methods.
I always found it frustrating how JLabel only really supported static images.
(This was once intended to be a very basic game engine, but I've since lost interest)
-
Layout managers cause the sprites to behave wierdly, so they usually have to be deactivated.
-
I worked on this in my free time during high school so it may have problems here and there. If you find one, report it! I may look into it.
JBurst requires a JDK of at least 1.8.
The binaries for the latest release can be found in the releases tab.
Maven users will need to add a few extra nodes to their pom.xml
in order to use it:
- First, this repository's
mvn-repo
branch must be included as a repository
<repositories>
...
<repository>
<id>jburst-home</id>
<name>jburst-home</name>
<url>https://raw.github.com/jbb248/jburst/mvn-repo/</url>
<releases>
<!-- Checksums haven't been working, so this ignores a long-winded warning. -->
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
</repositories>
- Second, the package must be included as a dependency
<dependencies>
...
<dependency>
<groupId>com.github.jbb248</groupId>
<artifactId>jburst</artifactId>
<version>0.5.1</version>
</dependency>
</dependencies>
Note: Due to the nature of the maven repository, only one version can be hosted at a time. As JBurst recieves updates, older versions will no longer be available through this method and will need to be added locally. This stack overflow question should be able to relieve any confusion on how to do that.
Then it's as simple as:
import javax.swing.JFrame;
import com.github.jbb248.jburst.JBurstSprite;
public class App
{
public static void main(String[] args)
{
JFrame window = new JFrame("Example");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(500, 500);
window.setLayout(null); // This line is important!
int x = 50, y = 50;
int frameWidth = 100, frameHeight = 150;
int[] frameIndices = new int[] {0, 1, 2, 3};
int frameRate = 30;
boolean looped = true;
JBurstSprite sprite = new JBurstSprite(x, y);
sprite.loadAnimatedGraphic("my-spritesheet.png", frameWidth, frameHeight);
sprite.animation.add("idle", frameIndices, frameRate, looped);
sprite.animation.play("idle");
sprite.start();
window.add(sprite);
window.setVisible(true);
}
}
-
A more in depth example using JBurst can be found here.
-
A small project using JBurst can be found in demo.zip.
- JBurst uses json-simple-1.1.1 for json support.
There are things that I definitely do not know about Swing and other things that I'm unfamiliar with regarding Java. So, if you have any suggestions (or warnings) let me hear them.
If you enjoy using this, give HaxeFlixel a shot. A large amount of JBurst's animation system is modeled on their game engine, so it would feel wrong not to mention them.