Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: jfarwyke on Wed 17/02/2010 15:30:31

Title: Fading out a character to reveal another character (SOLVED)
Post by: jfarwyke on Wed 17/02/2010 15:30:31
Whenever my playable character dies in the game, I wanted him to fade out, while his soul (now in his position floats off the screen. Originally, I thought the soul would just be another view. But I don't know how to fade one view into another, so I devised making the soul an NPC and well, basically, here's the die function I made in the global...


function die() {
   StopMusic();
   PlayMusic(5);
   int trans = player.Transparency;
while (trans < 100) {
 trans++;
 player.Transparency = trans;
 cJiva1.FollowCharacter(player, FOLLOW_EXACTLY, 1);
 cJiva1.Walk(Random(340), 0, eNoBlock, eAnywhere);
 Wait(1);
}
   gDead.Visible = true;
   gDead.Centre();
   mouse.Mode = eModePointer;
}


Because I don't know what room the player will be in or what screen position he'll be in when he dies, it's difficult for me to figure how to bring the NPC (Jiva1)  in. The reason I've used FollowExactly is so that he'll appear directly behind the player. And then after the player fade's out, there's the NPC floating away. But again, how do I script "bring cJiva1 into player's current room on player's current position"?

I was up all night working on this and am ready to give up on it altogether.
Title: Re: Fading out a character to reveal another character
Post by: NsMn on Wed 17/02/2010 15:42:22
cJiva1.ChangeRoom(player.Room, player.x, player.y);
Title: Re: Fading out a character to reveal another character
Post by: Matti on Wed 17/02/2010 16:05:59
If it's okay to fade the character OUT and then IN with the new view, you could do something like this:


// if character is dead

if (cChar.Transparency<100 && cChar.View==living) cChar.Transparency++;

if (cChar.Transparency==100 && cChar.View==living) cChar.View=dead;

if (cChar.Transparency>0 && cChar.View==dead) cChar.Transparency--;
Title: Re: Fading out a character to reveal another character
Post by: jfarwyke on Wed 17/02/2010 16:43:14
Well, I almost have it working. And it looks pretty good except my NPC (Jiva1) doesn't Walk anywhere. I think it's because of the Wait(1). I need that for the transparency. If I eBlock Jiva1's Walk, then he will walk fine but player will never fade out. It's just several Jiva1s after another coming out of him forever. It looks bizarre. I was hoping that while player fade's out, Jiva1 floats out. Other than that it looks fine. I suppose I'll have to implement a timer in there somehow. Any suggestions on that?


function die() {
    StopMusic();
    PlayMusic(5);
    int trans = player.Transparency;
while (trans < 100) {
  trans++;
  player.Transparency = trans;
  cJiva1.ChangeRoom(player.Room, player.x, player.y);
  cJiva1.Walk(Random(340), 0, eNoBlock, eAnywhere);
  Wait(1);
}
    gDead.Visible = true;
    gDead.Centre();
    mouse.Mode = eModePointer;
}


With the above code, he appears and animates, he just doesn't move to any location.
Title: Re: Fading out a character to reveal another character
Post by: GarageGothic on Wed 17/02/2010 16:45:44
Check out the Tween module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=38015.0), it lets you do non-blocking fades without worrying about scripting your own timer.
Title: Re: Fading out a character to reveal another character
Post by: jfarwyke on Wed 17/02/2010 16:58:51
Quote from: GarageGothic on Wed 17/02/2010 16:45:44
Check out the Tween module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=38015.0), it lets you do non-blocking fades without worrying about scripting your own timer.

I don't know if I'm ready to spoil myself with modules yet. Maybe after I've messed around with it some more, I'll give it a try. Thanks for the suggestion, I've saved the link.

EDIT:

Hey, check it out, it works now. I just moved the Jiva commands is all.


function die() {
    StopMusic();
    PlayMusic(5);
    cJiva1.ChangeRoom(player.Room, player.x, player.y);
    cJiva1.Walk(Random(340), 0, eNoBlock, eAnywhere);
    int trans = player.Transparency;
while (trans < 100) {
  trans++;
  player.Transparency = trans;
  Wait(1);
}
    gDead.Visible = true;
    gDead.Centre();
    mouse.Mode = eModePointer;
}


It looks great, thanks guys.