Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: My 'For' loop doesn't work  (Read 3575 times)

0 Members and 1 Guest are viewing this topic.

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
My 'For' loop doesn't work
« on: May 24, 2008, 05:28:48 PM »

Hi

I have a 'For' loop in a Window to fade music out:

for(a=100; a<1; a=a-1)
  {
  Game.Msg("MusicFade"+a);
  Game.SetMusicChannelVolume(3, a);
  Sleep(100);
  }
Game.StopMusicChannel(3);

I've made it extreme - a ten second fade - just to check it. It jumps straight to the 'Stop' - I get nothing from the Game.Msg so it's not going through the loop at all.

I guess I must have made some stupid syntactical error. I hope someone can spot it because it will probably also explain why my Static fades don't work either;

TextAlone = this.GetControl("TextAlone");
TextAlone.Visible = true;
TextAlone.AlphaColor = MakeRGBA(255,255,255,1);
// Fade up
for(a=1; a<256; a=a+1)
  {
  WMLogo.AlphaColor = MakeRGBA(255,255,255,a);
  TextAlone.AlphaColor = MakeRGBA(255,255,255,a);
  Sleep(5);
  }
  Sleep(1000);
//  Fade down
for(a=255; a<1; a=a-1)
  {
  WMLogo.AlphaColor = MakeRGBA(255,255,255,a);
  TextAlone.AlphaColor = MakeRGBA(255,255,255,a);
  Sleep(5);
  }
TextAlone.Visible = false;

Cheers
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: My 'For' loop doesn't work
« Reply #1 on: May 24, 2008, 05:42:51 PM »

It should be:

for(a=100; a>1; a=a-1)

It says:

1) set the a variable to 100
2) as long as a is bigger than 1...
3) decrease a by one
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: My 'For' loop doesn't work
« Reply #2 on: May 24, 2008, 05:54:09 PM »

Ah, I think I get it - I was looking at the middle parameter as though it were a boundary and I need to think of it as being more like a 'while' condition.

That's a conceptual hangover from my 'BASIC' days, I suspect - 'for x=1 to 10... next x'

Thanks again
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: My 'For' loop doesn't work
« Reply #3 on: May 24, 2008, 06:06:37 PM »

You were right, that sorted out the Music fade.

What can't understand is why the Static fades don't work. I've checked the code with fades I have in scenes where I'm fading a node in and out and it seems the same. It just doesn't seem to work in the Window. What have I missed?
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: My 'For' loop doesn't work
« Reply #4 on: May 24, 2008, 06:09:33 PM »

Forgot to add the code

var GameLogo = this.GetControl("GameLogo");
GameLogo.Visible = true;
GameLogo.AlphaColor = MakeRGBA(255,255,255,1);
for(a=1; a<256; a=a+1)
  {
  GameLogo.AlphaColor = MakeRGBA(255,255,255,a);
  Sleep(5);
  }
  Sleep(1000);
for(a=255; a>1; a=a-1)
  {
  GameLogo.AlphaColor = MakeRGBA(255,255,255,a);
  Sleep(5);
  }
GameLogo.Visible = false;

The static appears and disappears, but does't fade. It works fine in Scenes.
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: My 'For' loop doesn't work
« Reply #5 on: May 24, 2008, 06:31:50 PM »

That's because controls don't support AlphaColor changing. Only entire windows can be tinted or made semi-transparent.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: My 'For' loop doesn't work
« Reply #6 on: May 24, 2008, 06:45:05 PM »

Ah - the AlphaColor attribute is listed in the documentation as being used with Static controls. Sorry if I've misunderstood that entry.

Can I put that capability on the wish list please?
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com
 

Page created in 0.034 seconds with 19 queries.