Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: SGK on Mon 02/08/2004 00:07:57

Title: Transparency in background frames
Post by: SGK on Mon 02/08/2004 00:07:57
Ok i need rather urgent for someone to solve this. Im trying to make a background to fade from white to black slowly, thats why i just didnt make another room and put crossfade..

My game is hi-color, so no problems about that. The problem is that when executing this script in the room:

// room script file

function room_a() {
Ã,  // script for room: Player enters screen (before fadein)
SetBackgroundFrame(1);
RawDrawFrameTransparent(1, 99);Ã, 
}

function room_b() {
Ã,  // script for room: Player enters screen (after fadein)
SetCharacterView(EGO, 7);
Wait(20);
RawDrawFrameTransparent(1, 95);
RawDrawFrameTransparent(1, 90);
RawDrawFrameTransparent(1, 85);
RawDrawFrameTransparent(1, 80);
RawDrawFrameTransparent(1, 75);
RawDrawFrameTransparent(1, 70);
RawDrawFrameTransparent(1, 65);
RawDrawFrameTransparent(1, 60);
RawDrawFrameTransparent(1, 55);
RawDrawFrameTransparent(1, 50);
RawDrawFrameTransparent(1, 45);
RawDrawFrameTransparent(1, 40);
RawDrawFrameTransparent(1, 35);
RawDrawFrameTransparent(1, 30);
RawDrawFrameTransparent(1, 25);
RawDrawFrameTransparent(1, 20);
RawDrawFrameTransparent(1, 15);
RawDrawFrameTransparent(1, 10);
RawDrawFrameTransparent(1, 05);
RawDrawFrameTransparent(1, 00);Ã,  Ã, 
}


it gives this error message:

---------------------------
Adventure Game Studio
---------------------------
An error has occured. Please contact the game author for support, as this
problem is caused by the game rather than the interpreter.
(ACI version 2.56.627)

(Room 13 script line 6)
Error: RawDrawFrameTransparent: cannot draw current background onto itself

---------------------------
OKÃ,  Ã, 
---------------------------


I dunno how to not draw it on itself.... didnt get it.. someone can help me?

EDIT: by the way, the background is a white image and the frame is black. Ive put one frame only.
Title: Re: Transparency in background frames
Post by: Gilbert on Mon 02/08/2004 02:58:16
That's because you're already on frame 1, you cant raw draw frame 1 itself directly on itself.
So you probably need to raw draw frame 1 on frame 0, if you just want it to fade to black, import a bg of pure darkness of the same size into frame 1 (though I think you can also use TintScreen() for it, and it's probably even better).
Moreover, you have to Wait() after each rawdrawing, for simplicity and readibility, I'll change it to a while loop (also read the note in the manual, about restoring the screen):

// room script file

function room_a() {
  // script for room: Player enters screen (before fadein)
  SetBackgroundFrame(0);
  RawDrawFrameTransparent(1, 99); 
}

function room_b() {
  // script for room: Player enters screen (after fadein)
  SetCharacterView(EGO, 7);
  Wait(20);
  RawSaveScreen();
  int ii=100;
  while (ii>0) {
      RawRestoreScreen();
      RawDrawFrameTransparent(1, ii);
      Wait(1);
      ii-=5;
  }
}
Title: Re: Transparency in background frames
Post by: SGK on Tue 03/08/2004 02:31:23
how/where do i put the tintscreen thing?
Title: Re: Transparency in background frames
Post by: Gilbert on Tue 03/08/2004 02:46:52
Just where you want the effect to happen, and you don't need another frame for it. Like in your case:

function room_a() {
  // script for room: Player enters screen (before fadein)
  //SetBackgroundFrame(0); //Not needed
  //RawDrawFrameTransparent(1, 99); 
}

function room_b() {
  // script for room: Player enters screen (after fadein)
  SetCharacterView(EGO, 7);
  Wait(20);
  int ii=100;
  while (ii>0) {
      TintScreen(ii,ii,ii);
      Wait(1);
      ii-=5;
  }
}

Unfortunately, I'd checked, and seems that TintScreen() won't make the the screen as dark as expect even when using (1,1,1), if you want it to become REAL dark, TintScreen() may not be a good solution.
Title: Re: Transparency in background frames
Post by: strazer on Tue 03/08/2004 03:12:13
Is there a reason why you don't want to use the
FadeOut (int speed)
function?
Title: Re: Transparency in background frames
Post by: Gilbert on Tue 03/08/2004 03:17:57
Yeah FadeOut() works too, but in case he wants more control over the process. (For example, I'll never use FadeOut() myself).