Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
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  
  Sprite Sheet Splitting  (Read 3550 times)
0 Members and 1 Guest are viewing this topic.
Offline jparril1

Junior Member





« Posted 2011-04-03 04:28:40 »

Hey Guys,

     So Ive been reading about having your game split up a sprite sheet automatically and use frames for animations. It makes sense and all, but what I dont get is how to get the images to appear correctly. What I mean is, normally without a sprite sheet, Ive been taking a single image into photoshop and using the lasso tool to cut out the background. With a sprite sheet, if the program is just creating an image from a certain piece of the big sprite sheet image, it is going to be cutting out a rectangle shaped image. How am I going to get rid of the background so that the image actually looks correct and not an image drawn on some rectangle? Get what I mean? The background, whatever color it may be, will still be visible where ever there is no image within the rectangle.
Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2011-04-03 04:32:59 »

In the big sprite sheet, use a transparent background. For this you will need to use it in PNG format.

Offline jparril1

Junior Member





« Reply #2 - Posted 2011-04-03 04:54:45 »

So If I get a sprite sheet off the web, I'm guessing that the backgrounds aren't transparent right? Is there a way to make it transparent? If not, how do I even go about making my own sheet with a transparent background?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2011-04-03 05:30:51 »

You can manually edit it to have a transparent background. Have you heard of Paint.NET?

Offline jparril1

Junior Member





« Reply #4 - Posted 2011-04-03 06:03:22 »

Well I have photoshop CS3, would that work?
Offline BoBear2681

JGO Coder


Medals: 18



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

An alternative to ra4king's suggestion is to pick a specific color to represent "translucent background," a color that isn't used in any of your actual sprites.  In your sprite sheet, have all your sprites on that color background.  Then, when your game loads the sprite sheet image, have it do so into a BufferedImage, and convert all pixels with rgb==your translucent background color to a 0-alpha color, such as new Color(0x000000).  This can cut down on the size of your PNG's (useful for applets moreso than desktop games).
Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


I'm the King!


« Reply #6 - Posted 2011-04-03 06:36:22 »

@BoBear
Yes I was thinking of that solution but most sprite sheets you find online have a translucent background already. Plus it's not practical if the background color is also used in the images.

Offline pjt33
« Reply #7 - Posted 2011-04-03 08:52:04 »

Plus it's not practical if the background color is also used in the images.
Hence magic pink. Real graphics artists (as opposed to developers who make their own graphics) consider the use of #ff00ff in the image as abhorrent as the use of Comics Sans in the text.
Offline jparril1

Junior Member





« Reply #8 - Posted 2011-04-03 17:21:01 »

So having a translucent background doesnt necessarily mean that when I look at the sprite sheet I cant see the background right? For instance I have a sheet with a kind of blueish background, is it possible that it is translucent when actually rendered into a program?
Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


I'm the King!


« Reply #9 - Posted 2011-04-03 21:18:22 »

No, if you have a background that is not translucent, you have to have a method in your code that will check each pixel for that color and change it to 0-alpha.

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

Junior Member





« Reply #10 - Posted 2011-04-04 15:46:41 »

No, if you have a background that is not translucent, you have to have a method in your code that will check each pixel for that color and change it to 0-alpha.

Ok, so if I make my own sheet, is there some way to make it translucent in photoshop? Im guessing by just erasing the background that will make it translucent? Checking each pixel seems like unnecessary work, Id rather just make the background translucent to begin with.
Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


I'm the King!


« Reply #11 - Posted 2011-04-04 15:51:02 »

The simplest way is to "cut up" the image and paste it on a new image with a translucent background.

Offline steveyO
« Reply #12 - Posted 2011-04-05 14:31:09 »

1  
Ok, so if I make my own sheet, is there some way to make it translucent in photoshop? Im guessing by just erasing the background that will make it translucent? Checking each pixel seems like unnecessary work, Id rather just make the background translucent to begin with.

Never used Photoshop but can imagine this is correct.  If you have Gimp this can be done in 3 easy steps.  Firstly add a Transparent Layer (alpha channel), then use the select by Colour tool.. (Select the colour you wish to use for transparency), then delete the selected colour and save as .png as mentioned previously.  Many tutorials how to do this on google.

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
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.

pw (36 views)
2014-07-24 01:59:36

Riven (37 views)
2014-07-23 21:16:32

Riven (25 views)
2014-07-23 21:07:15

Riven (27 views)
2014-07-23 20:56:16

ctomni231 (57 views)
2014-07-18 06:55:21

Zero Volt (49 views)
2014-07-17 23:47:54

danieldean (39 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!