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 / SetSpriteColor() How to restore initial appeareance?

Author
Message
LeGugusse
17
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 29th Apr 2016 14:28
Hi
I'm using SetSpriteColor to color a sprite when it's selected by clicking on it.

But I want to be able to restore the initial appeareance ( cancel SetSpriteColor effect) when I deselect it.

But even when I don t know how to cancel the SpriteColor effect!

Thanks for your help!
Cry \"Havoc!\" and let slip the dogs of war
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 29th Apr 2016 14:37
SetSpriteColour( sprite, 255, 255, 255, 255 )
Does the job. On the face of it, it appears to be setting everything to white but it doesn't, it resets the effects of changing the color.
AGK V2 user - Tier 1 (mostly)
LeGugusse
17
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 29th Apr 2016 14:46
Yes it works!
THANK YOUUUUUUUUU!!!!
Cry \"Havoc!\" and let slip the dogs of war
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 1st May 2016 09:47
So then how would you set the sprite colour to white? or does the command hold a state and reverse it?
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Dybing
13
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 1st May 2016 10:09 Edited at: 1st May 2016 10:11
I just use a sprite with two frames for my buttons. Frame 1 is its' rest state, and frame 2 is for when the button is highlighted. If I wanted to, I guess I could add a third frame for when a button is actually pressed. Come to think of it, I need to come up with a more efficient routine for handling buttons. The one I use now is a bit convoluted. Now I check X and Y positions, and if the mouse pointer is within Y->Y+n && X->X+n area of a given button it highlights.

A snippet to show how it works with two buttons next to eachother on the same row:



This is hardly elegant however, and I am not to sure if it is all that efficient either. If anyone got a better solution, I'd love to see it
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 1st May 2016 10:30 Edited at: 1st May 2016 10:30
Quote: "So then how would you set the sprite colour to white? or does the command hold a state and reverse it?"


The sprite is white from the start, like a sheet of paper. When you paint on it (add an image) you get perfect bright colors. When you alter the color of the sprite from white you basically remove colors, thus the image turns darker. There is currently no way to overlay a color on top of the image. You need to create another sprite with a full white version of your image, and place it on top of your original sprite. Then you can alter the alpha of the overlaying sprite.

Login to post a reply

Server time is: 2024-11-25 07:27:45
Your offset time is: 2024-11-25 07:27:45