Hello, I am looking for a simple sprite animation class

Hello, I’m new and moving to Java. I have a simple C/C++ background, as well as some .NET programming. My last coding practice was a Sprite Animation Class in Visual Basic .NET.

I’m quickly looking for an example Sprite Class in Java, without having to hunt down code while I get my bearings with the Language.

I’m using the latest Java SE with Eclipse.

Could someone please drop some code in this thread that I can readily just run and load one of my animated sprites into? I just want to get a simple sprite animation loop with basic timing up and running.

The reason I moved to Java is because of the readily available libraries that are high performance. So if possible, I would like to try this with LWJGL or something similar, that can do OpenGL rendering.

Since I have never used any of the libraries, I don’t also expect a tutorial on one, but just maybe a quick link to getting it up and running. I’m already looking at LWJGL.

Thank you, and if you can help, this will give me a good idea on what to expect from Java in terms of coding.

:persecutioncomplex:

If we have absolutely no idea how your animated sprites work (are they a spritesheet, some special file, etc.), we won’t be able to help you. It would be best if you explained how your sprite animation files work.

[quote]Could someone please drop some code in this thread that I can readily just run and load one of my animated sprites into? I just want to get a simple sprite animation loop with basic timing up and running.
[/quote]
If we give you a fish to eat for supper tonight, you’ll be satisfied for a day but will quickly starve to death. If we teach you how to fish you’ll have food for as long as you need. It’s much better if learn how to animate the sprite rather than we give it to you directly. I’m not saying to learn alone without help, I’m suggesting we give you some basic idea of what to do and then you figure it out on the way. I also recommend learning more of the language first before attempting rather difficult (for beginners) things to do.

If you want a library that can do OpenGL rendering that’s not too complicated to use, you can use LibGDX. It’s like a wrapper for OpenGL that simplifies rendering and other utilities. You can even port to iOS, Android or HTML.

Java is a lot like C#, if you have any experience with it. Java isn’t the most fabulous programming language to make games in, but it’s still a programming language nonetheless. The major advantage to Java is that it’s a “compile-once, run anywhere” type of language.

In short, tell us how your animation files work, we’ll give you some things to start with and hopefully you can figure out the rest. If you get stuck feel free to ask us!

Good luck on your Java adventure! :point:

As chrislo27 said, we have no idea what your needs are without knowing what you’re trying use for this purpose.

I’m not going to paste some code, but I can give you a general idea for a crude animation.

First of all, whatever your means of storing individual graphics is, you’re going to need to store them in a way you can easily iterate through them. You need a timing mechanism(how quickly does this animation cycle through its frames?) An index for the current frame of the animation is needed. You need to decide what kind of functionality you want them to have. Do you want them to be a one-shot deal? Do you want them to repeat a certain number of times? Loop infinitely? Be played in reverse? Or even have it to where you can have an animation that only has one frame?

Depending on your needs and current knowledge, you could make a simple animation class from the questions I wrote. I’m not sure how helpful my post has been, I got off work not too long ago and it’s almost 2 am here. We’ll definitely try to help as much as we can when we’re given more information.