Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Sprite frame opacity  (Read 3300 times)

0 Members and 1 Guest are viewing this topic.

Malasieno

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 28
  • 3D Animation / Musical Score
    • View Profile
    • www.malasieno.com
Sprite frame opacity
« on: September 27, 2006, 01:21:25 AM »

Hello everyone,

perhaps i am too tired now to see the solution, but how can i change opacity in a frame, inside a sprite?
I mean... in sprite editor there is a parameter that controls frame opacity from 0 to 255, is there a script way to change this?

bye.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Sprite frame opacity
« Reply #1 on: September 27, 2006, 07:29:29 AM »

To programatically set opacity of an individual sprite frame you have to query the frame object and set its AlphaColor property. Something like this:

Code: [Select]
var SomeFrame = SomeSprite.GetFrame(10);
SomeFrame.AlphaColor = MakeRGBA(255, 255, 255, 128);

This will set the alpha value of the 11th frame to 128.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

greg

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
    • View Profile
Re: Sprite frame opacity
« Reply #2 on: October 02, 2006, 03:25:59 AM »

Hi All,

Is a sprite's alpha channel independent of its AlphaColor?  After reading through the documentation and forum, my understanding is as follows:

1. The alpha channel is a greyscale mask placed over an image that determines the transparency of various parts of the image.  (Black on the mask corresponds to an opaque part of the image, whereas white corresponds to a completely transparent part of the image.  Intermediate values--namely, greys--correspond to a partially transparent parts of the image.)

2. The AlphaColor determines the transparency of the entire image.  For example,

SomeFrame.AlphaColor = MakeRGBA(255, 255, 255, 0);    // fully transparent
SomeFrame.AlphaColor = MakeRGBA(255, 255, 255, 128); // partially transparent
SomeFrame.AlphaColor = MakeRGBA(255, 255, 255, 255); // fully opaque

Is this accurate?  In setting the AlphaColor with MakeRGBA(red_value, green_value, blue_value, alpha_value), would {red,green,blue}_value ever be set to a non-255 value?  If so, how would this affect the image?

Thanks so much for your help!

Greg
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Sprite frame opacity
« Reply #3 on: October 02, 2006, 07:41:03 AM »

Yes, that's right. The alpha channel is stored in the image and affects individual pixels. WME's AlphaColor attribute affects the entire game object (entity, actor, window..). Note that alpha channel transparency and AlphaColor transparency are combined.

Quote
In setting the AlphaColor with MakeRGBA(red_value, green_value, blue_value, alpha_value), would {red,green,blue}_value ever be set to a non-255 value?  If so, how would this affect the image?
Those three RGB values affect the color tint of the image. RGB(255, 255, 255) is white (i.e. no change). If you used, for example, (0, 0, 255), your sprite would get bluish tint.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.089 seconds with 21 queries.