Author Topic: ModulateAlpha for sprites on a specific layer  (Read 9909 times)

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: ModulateAlpha for sprites on a specific layer
« Reply #15 on: 2008-03-10, 05:29:55 PM »
There's a problem with reading the ModulateAlpha value because the C# ">>" operator didn't work the way I expected.  You can make this change in SpriteBase.cs to fix it:
1) Find "public int ModulateAlpha"
2) Change the code in the get accessor from:
return color >> 24;
to:
return 0xFF & color >> 24;

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: ModulateAlpha for sprites on a specific layer
« Reply #16 on: 2008-03-10, 05:30:34 PM »
Huzzah!  Interesting that it worked just fine for me?  Or is that only a fix for reading that value?  The method I showed never actually reads that value.
Edward Dassmesser

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: ModulateAlpha for sprites on a specific layer
« Reply #17 on: 2008-03-10, 05:36:51 PM »
It will only behave strangely if alpha is larger than 127, causing the overall color integer to be negative (by setting the sign bit).  Apparently the right shift operator fills the emptied bits with the sign bit for signed integers.  And yes, it only affects alpha because that's the high-order byte in the color integer.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: ModulateAlpha for sprites on a specific layer
« Reply #18 on: 2008-03-11, 02:57:13 AM »
thank you bluemonk, it works! i believed it must be something in the source code, and not my script. now is everything fine.  ;D
now, if the zeppelin is flying through a cloud, it gets wet and drips. it looks fine. with a gravity which goes upwards one could make really cool looking bubbles if the player is under water.
and also thank you, durnurd, for your help.  ;)