Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How can I make the white color transparent to show correctly my sprite?

Author
Message
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 18th Oct 2012 15:11
Hi guys, I am trying to make my 2D game where a man can move all over the screen.

here the code for main sprite :
Quote: "
// load png image
imageA = LoadImage ( "uomo_test_frames.png" )

// create a sprite from imageA
spriteA = CreateSprite ( imageA )
SetSpriteAnimation ( spriteA, 78, 125, 4 )
PlaySprite ( spriteA, 10, 1, 1, 4 )
"


Ok, my sprite is taken from a png image. This image is a grid made by many 78x125 pixels cells. (please take a look on the attached png image)

You can notice the image is made by more than 4 frames (how I set in my code) but for my test I need just of first 4 frames.
Ok I got my sprite on the screen and it's cycling the frames!
All good BUT!..

I got my sprite inside a white box during the game..
I know that there is the issue about trasparency of one colour (the png image background colour) but my knowledge about finish here
Please, how I can make the white colour of png image as transparent from AppGameKit code?

Thanks!

Attachments

Login to view attachments
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 18th Oct 2012 15:16
Yes, it is possible, but I can't remember the name of the command to set the transparency colour.

That is one pretty looking sprite!, whoever drew that has some serious pixel pushing skills. I would suggest though, if your using single colour transparency, don't use white or black, use magenta RGB(255,0,255) which is a fairly horrific purple colour that nobody would tend to use anywhere, for anything - so it's a popular transparency colour for pixel art.

I got a fever, and the only prescription, is more memes.
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 18th Oct 2012 15:25 Edited at: 18th Oct 2012 15:27
Hello Van B,
In first I would like to point out that I DON'T drawn that png picture! I take it from a free image site of sprites examples.

So, back to the problem, do you confirm me that exist one AppGameKit command that let the user to set the background image as trasparent?!
I searching about from sprite commands but I can't find it!

About the purple background color, you are total right about!
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 18th Oct 2012 15:32 Edited at: 18th Oct 2012 15:35
Maybe SetSpriteColorAlpha?? Trying...

mmm not..
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 18th Oct 2012 15:38 Edited at: 18th Oct 2012 15:39
Here, I just edited the image and optimized it for you;


Only 30KB larger then your original file.

Attachments

Login to view attachments
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 18th Oct 2012 15:44 Edited at: 18th Oct 2012 15:45
Ahh you changed the png image trasparency colour!..

Thank you very much mate

Login to post a reply

Server time is: 2024-05-04 17:22:55
Your offset time is: 2024-05-04 17:22:55