Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Moving Images  (Read 2874 times)
0 Members and 1 Guest are viewing this topic.
Offline jparril1

Junior Member





« Posted 2011-03-22 23:11:56 »

Hey Guys,

      So far all Ive made is games where I use static images for characters and enemies, and it looks really cheesy. How can I create a real looking animation, nothing fancy, like original zelda for instance? Im guessing I need to use sprites? I want the character to actually move its legs or swing a sword, and not just look like an image sliding around the screen. Any help?
Offline ReBirth
« Reply #1 - Posted 2011-03-23 02:30:03 »

Here the basic:
On your character class, hold mutiple sprites (do-nothing, attacking, etc) and show it regarding the character's condition right there. Update it through main game loop.

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #2 - Posted 2011-03-23 03:32:01 »

For animating sprites, you will need multiple images showing each movement and you will then rotate through each one. This is typically done with a SpriteBatch, a large image containing all the frames in their own box.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jparril1

Junior Member





« Reply #3 - Posted 2011-03-23 03:44:08 »

Ok so my current method of image loading is the use of ImageIcons and Images. Typical image code for me is this :

ImageIcon icon = new ImageIcon(this.getClass().getResource("filename.png"));
Image image = icon.getImage();

then I have the full image stored in image. Is this considered a good way to do it? So if I continue to use this method, I would just have multiple images in different actions and paint the appropriate one for each frame?

I kind of always thought that a sprite was always animated, but the term sprite just refers to a static image as well. So basically I am creating a sort of stop motion animation by changing poses of the character quickly?
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2011-03-23 03:48:35 »

I kind of always thought that a sprite was always animated, but the term sprite just refers to a static image as well. So basically I am creating a sort of stop motion animation by changing poses of the character quickly?
How else do you think animation is done? It's all stop motion basically, but so quickly that it's fluid.

EDIT:I should mention though, that if you only need to move an arm or head, you don't need multiple sprites. You could have an image of the arm or head move on a static image of the body. Grin

Offline jparril1

Junior Member





« Reply #5 - Posted 2011-03-23 04:06:31 »

Gotcha, Ok Im going to mess with this a bit. Any other advice on the subject is always welcome.
Offline aazimon
« Reply #6 - Posted 2011-03-23 15:24:07 »

There are several threads on this site which recommend loading images with ImageIO.read(File file). If you are interested a have a framework for handling animations. You can view the source code here http://www.abberkeep.us/projects/game/gameBase.htm. You just insert the frames (images) and call the update, and getImage to draw it. There are other things in there specific to my framework, you can just ignore those.
Offline Zushii

Senior Newbie





« Reply #7 - Posted 2011-03-23 15:39:10 »

I have alot of animations: idle, shooting, running an shooting etc. etc.

Now..uhm...(pls don't hurt me) I used animated gifs...(I can hear them chanting blashemy).

Okay no seriously. I started my first game this week and used already animated sprites. Works fine an such, too a certain extend.

Could somebody maybe give me a link to a tutorial on how to make such animations with sprites in one sprite sheet?
Offline aazimon
« Reply #8 - Posted 2011-03-23 16:14:36 »

Are you wanting to use the animtated gifs on your sprite sheet?
I standard sprite sheet is divided into animtated frames, such as this stick figure walking. This topic talks about cutting up the animation sheet. http://www.java-gaming.org/topics/animation-tiles/294/view.html

Offline Zushii

Senior Newbie





« Reply #9 - Posted 2011-03-23 16:26:22 »

cool thanks alot!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Zushii

Senior Newbie





« Reply #10 - Posted 2011-03-23 16:58:31 »

I can't get it to work.

It'S basicly what I want.

But do you have a full tutorial? Like how to use that to paint the animation.
Offline aazimon
« Reply #11 - Posted 2011-03-23 20:19:20 »

The basis of my code comes from David Brackeen's book "Developing Games in Java". I don't have a tutorial for this, but it should be in the on-line code at his site http://www.brackeen.com/javagamebook/. I'm at work so I don't know the chapter.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (28 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (75 views)
2014-09-10 06:39:09

Tekkerue (38 views)
2014-09-09 02:24:56

mitcheeb (57 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (28 views)
2014-09-07 01:12:14

Longarmx (34 views)
2014-09-07 01:11:22

Longarmx (35 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!