Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Troubles with alpha  (Read 5239 times)

0 Members and 1 Guest are viewing this topic.

mRax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 55
    • View Profile
Troubles with alpha
« on: March 30, 2007, 12:09:04 PM »

Hello!

Sometimes I have a strange trouble with alpha.

Code: Text
  1. w=Game.LoadWindow("scenes\test\w4.window");
  2. w.FadeTo(0,1,0,0,0);
  3. //e=w.GetControl("1");e=e.GetEntity();e.Rotatable=TRUE;e.Rotate=10;
  4. w.Visible=TRUE;
  5. w.FadeTo(1000,255,255,255,255);
  6. Sleep(10000);
  7. w.FadeTo(1000,1,0,0,0);
  8. w.Visible=FALSE;
  9. Game.UnloadObject(w);

.FadeTo() method is based on window's .AlphaColor property. So it works fine! But when I enable marked line (especially, e.Rotatable=TRUE; operator), the entity always becomes visible, and the changing of .AlphaColor doesn't take effect. If I write e.Rotatable=FALSE; operator, it works fine again. I'm embarassed :) What the matter? Is trouble in the entity container or something else?

Although, .Rotatable is worked. And .AlphaColor not :)

Here is the piece of advanced script, attached to window

Code: Text
  1. #include "scripts\base.inc"
  2.  
  3. var a0=255;
  4. var r0=255;
  5. var g0=255;
  6. var b0=255;
  7.  
  8. method FadeTo(duration,a,r,g,b){
  9.   if(a==NULL)a=0;
  10.   if(r==NULL)r=0;
  11.   if(g==NULL)g=0;
  12.   if(b==NULL)b=0;
  13.   var tmp=Scene.GetNode("temp_entity");
  14.   var t0=Game.CurrentTime;
  15.   tmp.AlphaColor=this.AlphaColor;
  16.   if(tmp.AlphaColor==NULL||tmp.AlphaColor==0){
  17.     a0=255;
  18.     r0=255;
  19.     g0=255;
  20.     b0=255;
  21.   }
  22.   //Game.LOG("=WINDOW "+this.Name+" FADES=");
  23.   //Game.LOG("FROM: "+a0+" "+r0+" "+g0+" "+b0);
  24.   //Game.LOG("  TO: "+a+" "+r+" "+g+" "+b);
  25.   while(TRUE){
  26.     var dt;
  27.     if(duration>0)dt=(Game.CurrentTime-t0)/duration;else dt=1;
  28.     if(dt<0)dt=0;
  29.     if(dt>1)dt=1;
  30.     tmp.AlphaColor=0;
  31.     tmp.AlphaColor=tmp.AlphaColor*256+a0+(a-a0)*dt;
  32.     tmp.AlphaColor=tmp.AlphaColor*256+r0+(r-r0)*dt;
  33.     tmp.AlphaColor=tmp.AlphaColor*256+g0+(g-g0)*dt;
  34.     tmp.AlphaColor=tmp.AlphaColor*256+b0+(b-b0)*dt;
  35.     this.AlphaColor=tmp.AlphaColor;
  36.     if(dt==1){
  37.       if(a==255&&r==255&&g==255&&b==255)this.AlphaColor=NULL;
  38.       a0=a;
  39.       r0=r;
  40.       g0=g;
  41.       b0=b;
  42.       break;
  43.     }
  44.     Sleep(50);
  45.   }
  46. }
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Troubles with alpha
« Reply #1 on: March 30, 2007, 09:24:58 PM »

this is some heavy coding. Any reason why you don't use MakeRGBA? Are you sure your alpha color is set properly?

I think alpha works well even for rotated sprites.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Troubles with alpha
« Reply #2 on: March 31, 2007, 01:02:42 PM »

I tried rotating an entity and setting its AlphaColor - works ok. I tried the same with an entity embedded into an entity container - also works. If you can make some minimal example exhibiting your problem, I'll look into it.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

mRax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 55
    • View Profile
Re: Troubles with alpha
« Reply #3 on: April 02, 2007, 12:18:00 PM »

Thanks for help!

Any reason why you don't use MakeRGBA?

Gya-a! :o Now I use MakeRGBA()! :D

Are you sure your alpha color is set properly?

Yes, I'm sure. It's worked fine, when .Rotatable property is FALSE

I tried the same with an entity embedded into an entity container - also works

It's strange. I have bad feelings ::) Maybe, I misunderstand something. Anyway...

Code: Text
  1. //e=w.GetControl("1");e=e.GetEntity();e.Rotatable=TRUE;e.Rotate=350;

If I erased "//", the entity turned to angle, but .FadeTo() method broke suddenly. (So "1"'s entity didn't appear slowly)

Code: Text
  1. c=w.GetControl("1");
  2. e=c.GetEntity();
  3. e.FadeTo(0,0,0,0,1);
  4. c.Visible=TRUE;
  5. e.FadeTo(TIME,255,255,255,255);

Entity .FadeTo() method didn't work at all, when the entity was in the entity container. (.AlphaColor property didn't have any effect)

Links.

The example (temporary file erased)
« Last Edit: April 04, 2007, 08:40:31 AM by mRax »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Troubles with alpha
« Reply #4 on: April 02, 2007, 06:33:09 PM »

That was a well disguised bug, thanks for your help. Fixed in the latest build.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

mRax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 55
    • View Profile
Re: Troubles with alpha
« Reply #5 on: April 03, 2007, 11:23:47 AM »

Thanks you too :)

Code: Text
  1. e=w.GetControl("1");e=e.GetEntity();e.Rotatable=TRUE;e.Rotate=350;

Now it worked properly.

And what about this?

Code: Text
  1. c=w.GetControl("1");
  2. e=c.GetEntity();
  3. e.FadeTo(0,0,0,0,1);    // entity must be transparent, but it isn't
  4. c.Visible=TRUE; // entity container appears "suddenly" (because of the entity is not transparent)
  5. e.FadeTo(TIME,255,255,255,255); // entity must fade in from transparent state, but there isn't any action

Did I make a mistake somewhere?  ???
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Troubles with alpha
« Reply #6 on: April 03, 2007, 06:42:51 PM »

It won't work, because for entity containers their alpha color is overridden by their parent window's alpha color.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

DocBass

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 136
    • View Profile
Re: Troubles with alpha
« Reply #7 on: July 22, 2008, 08:05:21 AM »

It won't work, because for entity containers their alpha color is overridden by their parent window's alpha color.

Is this still true? I have one window set up like this that I am easily controlling the alphas of entities within entity containers, and another window that is nearly identical that wont allow me to touch the alphas of entities within entity containers. Trying to figure out why is driving me mad.  :P
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Troubles with alpha
« Reply #8 on: July 27, 2008, 12:05:09 PM »

Yes, I believe this is still true.
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.106 seconds with 113 queries.