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 / whiten sprite?

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th Nov 2012 09:37
is there a way to make a coloured sprite with various colours, 100% white?

tried the setspritecolor command, which is great for colouring a white sprite, but not the other way round
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Nov 2012 09:41
You could have a pure white version of the image and make place a sprite using that image directly over you original. Then just set the alpha of the white sprite.


this.mess = abs(sin(times#))
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 9th Nov 2012 15:10
Perhaps a more efficient way would be to add an animation frame with the white version on? Unless it has a large animation already. That way you can just change the frame when you want it to become pure white.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th Nov 2012 22:20
well, i was thinking of an agk command that would get away with having white duplicates of all sprites!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Nov 2012 22:30
SetSpriteColor does affect sprites created from images that are non-white. I use it regularly.

Cheers,
Ancient Lady
AGK Community Tester
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Nov 2012 00:28
SetSpriteColor seems the only command that could do what I want, but it's impossible to whiten a colored image.

Can i use some command and use the outline shape of my sprite to cut a new sprite from a white square sprite?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 10th Nov 2012 01:24 Edited at: 10th Nov 2012 01:25
When I use SetSpriteColor on a colored image, it does affect the image. But, you are correct, if I try to just set all the colors to 255, it has no affect. Sorry. I had not tried making something whiter, just adding different shading.

Sounds like a white sprite overlapping the colored with setting alpha may be your only option.

Quote: "Can i use some command and use the outline shape of my sprite to cut a new sprite from a white square sprite?"

I don't think so. The issue is detecting edges. Theoretically the scissor commands might be used, but I think they are line/rectangular only.

Cheers,
Ancient Lady
AGK Community Tester
fog
21
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Newcastle, England
Posted: 10th Nov 2012 10:30
SetSpriteColor effectively just specifies the amount of colour to be displayed from the original image, you can't increase the ammount of RGB to make it white. (ie: x/255 * orig_colour)

Quote: "Can i use some command and use the outline shape of my sprite to cut a new sprite from a white square sprite?"

You could use SetImageMask() to automatically create the white sprites at load time, but it's too slow to use in your main game loop.

If your current images don't use and fancy alpha values then they will be 255 wherever you have a pixel. So copying this into the RGB parameters of your new image will create a white one.

Something like (pseudo):

//I think this is the only way of creating a new image to use
int whiteImage = agk::CopyImage( srcImage, 0, 0, agk::GetImageWidth( srcImage ) , agk::GetImageHeight( srcImage ) );

//Copy source image alpha to white image RGB channels
agk::SetImageMask( whiteImage , srcImage, 1, 4, 0, 0 );
agk::SetImageMask( whiteImage , srcImage, 2, 4, 0, 0 );
agk::SetImageMask( whiteImage , srcImage, 3, 4, 0, 0 );

Login to post a reply

Server time is: 2024-11-24 01:17:30
Your offset time is: 2024-11-24 01:17:30