Jump to content
  • Advertisement
Sign in to follow this  

[java] Animation strip question

This topic is 4739 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been working with an animation strip example from "Java 2: Game Development programming" and a question has occured to me. Animation strips are loaded and cut up into frames. You specify the rectangular size of each frame and the thickness of the grid. The animation strip example in this particular case was a robot walking in a certain direction. Here is my question: when the robot is rendered it is rendered over a background of tiles, but the tiles appear to disappear behing the robots body, not behind some rectangular block that includes the robot. In other words the rectanglar frame that includes the robot seems to be ignored but the robot is rendered. How did the animation classes know where the robot art began and what was "blue screen"-type background? Just curious, Battlefrog

Share this post


Link to post
Share on other sites
Advertisement
There are two ways they could be doing this. The "Blue Screen Effect" you describe is precicely one of them. Typically, a specific color is designated as the transparent color. Whenever the renderer comes accross a pixel that color, it doesn't draw it. This is exactly how the blue or green screen effect occurs with say, someone on the weather channel. All of the same rules apply of course- if your Robot happened to be wearing a tie the same color as the transparent color, then your Robot will be missing his neck! (Just like on TV!)

The second way is more up to date, and most commonly used today.

In the past, images typically held 3 "channels" of data- a Red, Blue, and a Green one. Each pixel would have 3 bytes of data corresponding to each pixel. A red pixel would have the value: (255, 0, 0) for example, meaning that it's red value was 100% saturated, while it's blue and green channels were not.

More Examples:
A white pixel would be (255, 255, 255)
Black (0, 0, 0)
The bluish background of this post would be (42, 44, 61).

Images nowadays can have more than just 3 channels. In the case of transparency, an "alpha" channel is used. This channel is used to designate the transluscence of a particular pixel. If I wanted a red pixel to be halfway transparent, it'd look like this: (255, 0, 0, 128). Whereas a fully transparent red pixel would be (255, 0, 0, 255). You can see, this allows more flexability. No color has to be omitted anymore since transparency is decided on a per pixel basis.

For more info you can look here: http://exchange.manifold.net/manifold/manuals/manifold/images/rgb_images_and_channels.htm

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!