We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Opaque background for sprites
Page Index Toggle Pages: 1
Opaque background for sprites? (Read 515 times)
Opaque background for sprites?
Jan 6th, 2009, 10:10am
 
I'm having trouble with a Lunar Lander program I created. This might not be an appropriate question because it doesn't have to do with the language itself, but how do I take an image I'm using as a sprite and make the background opaque, so that the edges of the image don't overlap onto other sprites?
Re: Opaque background for sprites?
Reply #1 - Jan 6th, 2009, 10:20am
 
I am sorry, but I fear I don't understand the question. Perhaps by lack of enough information.

In general, one want to have transparent background for a sprite, so when drawn it blends with scene background.

Beside, I don't get the "so that the edges of the image don't overlap onto other sprites" part. Can you illustrate the concept, somehow?

Is your sprite generated or is it the result of a loadImage?
Re: Opaque background for sprites?
Reply #2 - Jan 6th, 2009, 11:52pm
 
Yes, this sprite is being generated by the loadImage(); command and the image(); command. Take the example program built into Processing for sprites, it has the 'teddybear' image, but the edges of the image which aren't actually the sprite are opaque, so that if the sprite draws in front of a colored background, the image doesn't appear as a square image, it appears as the sprite. If you look at the 'teddybear' image from that sketch, you'll see what I mean. I'm wondering how you achieve the effect of opaqueness on my sprite image so I can have a sprite drawn on a screen, but not have the square effect that happens when you just load a normal image.
Re: Opaque background for sprites?
Reply #3 - Jan 7th, 2009, 11:43am
 
Uh? I fear I have to replace "opaque" by "transparent" in your previous message. Edges of the image are transparent so that colored background appears behind the image, and you want transparency of the sprite image.

Which is generally achieved by using transparency of the image file format: you can't have it with Jpeg images, you can have something primitive with Gif image (binary state: transparent or opaque, might not work well with some backgrounds) and something elaborate with PNG (full alpha channel).

So if your sprite is correctly generated (you must use a graphics editor handling transparency), it should naturally blend well with background.
Re: Opaque background for sprites?
Reply #4 - Jan 8th, 2009, 6:14am
 
Yes, I figured out how to do it.
Page Index Toggle Pages: 1