"object[0].Transparency--;" - Does that work?

Started by Ntimer, Thu 14/08/2008 23:08:25

Previous topic - Next topic

Ntimer

Hello, everybody...

I've got a little problem with AGS (Version 2.72). I'd like to make an Object fading in and fading out - while moving from the right side of the screen to the left side of the screen.
What my problem is: The object isn't fading in. I'm using
Code: ags
object[0].Transparency--;
to reduce the Transparency, but it doesn't work... That's very strange, because
Code: ags
object[0].Transparency++;
- which I am using to fade the object out again - is working perfectly.
I've tried many things to make it work (I've even deleted all the room-script code one time, only leaving this "object[0].Transparency--;" one time but it didn't help ^^), but nothing worked...

I don't understand it... Can you explain the problem to me or is it some kind of bug? :-\

Here is the complete room-script of that room - perhaps you'll find something. :)

Code: ags

#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
  // script for Room: First time player enters room
  while (object[0].X > -251) {
    object[0].X-=2;
    Wait (1);
    if (object[0].Transparency > 0){
      object[0].Transparency--;
    }
    else if (object[0].Transparency < 100){
			object[0].Transparency++;
		}
  }
}
#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart room_b  // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
  // script for Room: Player enters room (before fadein)
	object[0].X = 320;
	object[0].Transparency = 100;
}
#sectionend room_b  // DO NOT EDIT OR REMOVE THIS LINE


OK, this was it...
(Sorry if you didn't understand anything, this was the first time I posted something in an english Forum... ;))

SSH

Its probably due to rounding errors. Initialise a variable to be the transparency value, inc and dec the variable and then update transperncy with the varible.
12

Ntimer

Great! It worked. Many thanks. :)
Now I know why I should use variables to do things like these. ^^ 

Again, thanks for your help. ;)

SMF spam blocked by CleanTalk