Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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  
  Slicing up sprite sheets for complex characters.  (Read 1475 times)
0 Members and 1 Guest are viewing this topic.
Offline dah01

Junior Member


Medals: 7



« Posted 2011-12-31 05:57:45 »

If not best practices, could someone provide an example?

The issues that I'm facing are that the artist I'm working with and I have a player character that we want to animate that will be around 32 wide by 64 high.

He may have a spear, which may be 128 long.

Should we create one sprite sheet for that character with all of the animation stuff manually specified with xml or should we create three sheets, 64x64, 128x128, 256,256, etc?

EDIT: Think like secret of mana, evermore, beyond oasis.

The issue is since java draws from top left coordinates then we'll have to be constantly concerned about the offset of the sprite since his location will be in reality x and y away from the location that the top left of his sprite needs to be drawn at.
Online ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #1 - Posted 2011-12-31 07:19:52 »

I'm not quite sure I understand what your problem is?

If your character is 32x64, then have all the frames of his animation in 1 image that is (n*32)x64 (n being the number of frames).

And the only thing you should be worrying about is the X and Y position of your character in world coordinates. You should only be converting to screen coordinates when drawing.

Offline StumpyStrust
« Reply #2 - Posted 2011-12-31 09:36:40 »

I think I understand what you are saying. Although I I may not be the best person to answer this.

Basically the drawing will be all screwy because the top left corner you are drawing from is changing do to different sized sprites.

One idea is to have a default size for all sprites for a character, say 64*64, even though the walk animation may only be 32*64.

The other is to have any spears/weapons/magic have their own sprite and be drawn on top of the character. This may make collisions for attacking easier.

The last idea would be to calculate the offset for the different sized sprites and add/subtract them from your drawing coordinates.
This I think is the best.

Here is a video to show what I think is going on for those with more expertise.

http://www.youtube.com/watch?v=oJPe6cWIC-Q

 
Games published by our own members! Check 'em out!
Try the Free Demo of Revenge of the Titans
Online ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #3 - Posted 2011-12-31 09:58:30 »

Oh! I see what the OP means now. The easiest way is to make the spritesheet as tall as the tallest frame then just add alpha above the smaller ones. In a separate file (like the XML file you mentioned) you would set the offset for bounds checking against certain frames.

Just like in StumpyStrust's video, but all in 1 spritesheet:

Offline dah01

Junior Member


Medals: 7



« Reply #4 - Posted 2012-01-01 16:38:21 »

Wow, there are so many ingenious tricks involving images. I'll have to check out this video, hopefully I can find some code samples?
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (80 views)
2013-05-17 21:29:12

alaslipknot (89 views)
2013-05-16 21:24:48

gouessej (122 views)
2013-05-16 00:53:38

gouessej (114 views)
2013-05-16 00:17:58

theagentd (126 views)
2013-05-15 15:01:13

theagentd (113 views)
2013-05-15 15:00:54

StreetDoggy (158 views)
2013-05-14 15:56:26

kutucuk (180 views)
2013-05-12 17:10:36

kutucuk (180 views)
2013-05-12 15:36:09

UnluckyDevil (186 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.089 seconds with 20 queries.