Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gabarts on Sun 29/12/2013 14:05:15

Title: Cutscene (characters entering, leaving) [SOLVED]
Post by: Gabarts on Sun 29/12/2013 14:05:15
Hi, I'm trying to make this cutscene working but need to clarify some problems...

Check this picture...
(http://i39.tinypic.com/2vwbkex.jpg)

And here the code:

Code (ags) Select

function room_Load()
{
RemoveWalkableArea(2);
Overlay* myOverlay = Overlay.CreateTextual(6,135,300,eFontFont1,65504,"Qualche minuto dopo...");
Wait(200);
myOverlay.Remove();
}

function room_FirstLoad()
{

cMarcus1.Walk(150, 100, eBlock, eWalkableAreas);
cMarcus1.LockView(22);
cMarcus1.Animate(2, 3, eRepeat, eBlock, eForwards);
Wait(240);
cMarcus1.UnlockView();
}


-The cursor still appearing in the cutscene, don't know if possible to remove it at all...
-Marcus character is blocked in the loopDown view.
-The text overlay should appear while Marcus complete his actions but at the moment is not working

What I'd like to have is:

-Marcus walk to a zone x, y starting from outside the room (right)
-Indy (main cEgo character) entering the room from outside after a certain time

It's quite a while I don't use AGS, any help is much appreciated, thanks!
Title: Re: Cutscene (characters entering, leaving)
Post by: Dualnames on Sun 29/12/2013 21:19:12
You're using room_load, which occurs before the room fades in, what you need is to place your code after the room fades in, either on AfterFadeIn or on room FirstLoad (depending if you want this to happen everytime you join the room, or just once.)

Code (ags) Select

Overlay* myOverlay;
int timer_to_remove=0;//creating a timer for the overlay text

function room_Load()
{
  cMarcus.X=[insert room width + the character sprite width here];
  cMarcus.Y=[insert an ideal Y position];
  mouse.Visible=false;//turns the mouse off.
}

function room_AfterFadeIn()
{
RemoveWalkableArea(2);
myOverlay = Overlay.CreateTextual(6,135,300,eFontFont1,65504,"Qualche minuto dopo...");
cMarcus1.Walk(150, 100, eBlock, eWalkableAreas);
cMarcus1.LockView(22);
cMarcus1.Animate(2, 3, eRepeat, eBlock, eForwards);
Wait(240);
cMarcus1.UnlockView();
mouse.Visible=true;//turns mouse back on
}

function repeatedly_execute_always()
{//this handles the overlay without as blocking stuff occurs. It removes the overlay as if you used Wait(200);
  if (myOverlay!=null)
  {
     time_to_remove++;
     if (time_to_remove==200)
     {
       myOverlay.Remove();
     }
  }


}

Title: Re: Cutscene (characters entering, leaving)
Post by: Gabarts on Mon 30/12/2013 12:48:51
Many thanks :)

I will give this a try. I've made something similar for other rooms but it didn't work for this particular one.
I will let you know if all is ok!
Title: Re: Cutscene (characters entering, leaving)
Post by: Gabarts on Mon 30/12/2013 13:09:49
Nope, it's still not working. Marcus character it's still blocked in the x, y position and the animation doesn't start.

I've used this code for the credit room for my DEMO and here the text overlay is working but is centered, I want the text in a certain x, y position this time. Check:

Code (ags) Select
Overlay* textOverlay;

function ShowTextCentered(String text)
{
 
  int centerX, centerY;
  int textWidth, textHeight;
  int x, y;
 
  centerX = System.ViewportWidth / 2;
  centerY = System.ViewportHeight / 2;
 
  textWidth = GetTextWidth(text, eFontFont1);
  textHeight = GetTextHeight(text, eFontFont1, textWidth + 7);
 
  x = centerX - (textWidth / 2);
  y = centerY - (textHeight / 2);
 
  textOverlay = Overlay.CreateTextual(x, y, textWidth + 7, eFontFont1, 65504, text);
}

function room_AfterFadeIn()
{
  aAdventure_1.Play();
  ShowTextCentered("Grazie per aver provato la DEMO di");
  Wait(120);
  ShowTextCentered("Indiana Jones e l'Oro di Gengis Khan");
  Wait(120);
  ShowTextCentered("Idea, Grafica, Musica, Programmazione");
  Wait(120);
  ShowTextCentered("Gabriele Ciucchi");
  Wait(120);
  ShowTextCentered("Gabarts Copyright 2012.");
  Wait(120);
  ShowTextCentered("Sistema SCUMM originale e ispirazione");
  Wait(120);
  ShowTextCentered("Ron Gilbert, David Fox, Noah Falstein, Michael Land");
  Wait(180);
  ShowTextCentered("Quando la musica si ferma premi F5");
  Wait(120);
  ShowTextCentered("Se ci riesci...");
  Wait(120);
  textOverlay.Remove();
}


This is working for the text. But how to tell the text function I want the text in a certain x, y position instead of centered?

Still have to solve the character animation...
Title: Re: Cutscene (characters entering, leaving)
Post by: Dualnames on Mon 30/12/2013 16:44:37
Oh, lol.

eWalkableAreas this on my script needs to be eAnywhere.
Title: Re: Cutscene (characters entering, leaving)
Post by: Khris on Mon 30/12/2013 18:18:19
Quote from: Gabarts on Mon 30/12/2013 13:09:49This is working for the text. But how to tell the text function I want the text in a certain x, y position instead of centered?

Code (ags) Select
Overlay* textOverlay;

function ShowTextAt(String text, int centerX, int centerY)  // EDIT: DOUBLE { REMOVED

  int textWidth, textHeight;
  int x, y;
 
  // if not specified, show at screen's center
  if (centerX == -1) centerX = System.ViewportWidth / 2;
  if (centerY == -1) centerY = System.ViewportHeight / 2;
 
  textWidth = GetTextWidth(text, eFontFont1);
  textHeight = GetTextHeight(text, eFontFont1, textWidth + 7);
 
  x = centerX - (textWidth / 2);
  y = centerY - (textHeight / 2);
 
  textOverlay = Overlay.CreateTextual(x, y, textWidth + 7, eFontFont1, 65504, text);
}

function ShowTextCentered(String text) {
  ShowTextAt(text, -1, -1);
}

function room_AfterFadeIn()
{
  aAdventure_1.Play();

  ShowTextCentered("Grazie per aver provato la DEMO di");
  Wait(120);

  // show centered at y = 20
  ShowTextAt("Indiana Jones e l'Oro di Gengis Khan", -1, 20);
  Wait(120);

  ...
}


Now you can use ShowTextAt(text, x, y) to position the center of the message box arbitrarily. Pass -1 as either x or y to center on screen.

Edit: double { removed at start of first function's body.
Title: Re: Cutscene (characters entering, leaving)
Post by: Gabarts on Mon 30/12/2013 22:55:02
Fantastic, thanks Khris! ;-D

Now have to sort out the problem for the new character, he refutes to walk...
Title: Re: Cutscene (characters entering, leaving)
Post by: Crimson Wizard on Mon 30/12/2013 23:31:20
Quote from: Gabarts on Mon 30/12/2013 22:55:02
Fantastic, thanks Khris! ;-D

Now have to sort out the problem for the new character, he refutes to walk...

Have you tried previous suggestion by Dualnames (one post before Khris)?
Quote
eWalkableAreas this on my script needs to be eAnywhere.
Title: Re: Cutscene (characters entering, leaving)
Post by: Gabarts on Tue 31/12/2013 11:46:53
Yes, I've tried every solutions. At the moment I'm stuck with that, the new location appears, and I see Marcus character blocked at the starting position doing anything.

I've set Showplayercharacter to false, then I will need to make him appear again, but this I will find out later...
Title: Re: Cutscene (characters entering, leaving)
Post by: Dualnames on Tue 31/12/2013 13:27:18
No offense, but you've clearly didn't even bother with the code I've posted.
Title: Re: Cutscene (characters entering, leaving)
Post by: Gabarts on Tue 31/12/2013 14:30:05
Your code isnt' working. As a matter of fact even the Khris one for the overlay text is not working, so I think there must be something wrong in my room setup or similar...

I can post the folder zip with the game content if you want to check.
Title: Re: Cutscene (characters entering, leaving)
Post by: Dualnames on Tue 31/12/2013 14:35:02
Please do so.
Title: Re: Cutscene (characters entering, leaving)
Post by: Khris on Tue 31/12/2013 15:11:05
"Isn't working" is not enough. I found the error though; there was a redundant { at the start of the first function's body.
Title: Re: Cutscene (characters entering, leaving)
Post by: Gabarts on Tue 31/12/2013 16:57:48
Quote from: Khris on Tue 31/12/2013 15:11:05
"Isn't working" is not enough. I found the error though; there was a redundant { at the start of the first function's body.

Khris, those kind of errors AGS tells me before launching the compiled. That's not the problem. I will send you the zip as soon I can, to both of you guys how try helping me out. Thanks
Title: Re: Cutscene (characters entering, leaving)
Post by: Khris on Tue 31/12/2013 17:08:35
I don't know about the other thing, but I tested my code and it worked just fine (except for the additional curly bracket).
Title: Re: Cutscene (characters entering, leaving)
Post by: Gabarts on Tue 31/12/2013 18:11:40
Of course, if there are problems it's just because of some mess in my code, maybe some wrong passages in the other rooms. The weird thing is that the same code is working for my main character in the first room. Anyway, thanks for help and have a HAPPY NEW YEAR! :)
Title: Re: Cutscene (characters entering, leaving)
Post by: Gabarts on Wed 01/01/2014 19:01:25
All is working now...

Last thing to sort out:

In the room variables there is ShowPlayerCharacter
If I set to false how can I set it to true again in room script?

I've used x, y coordinates to put my main character out of the room screen but instead he's appearing right next to the right edge of the room after Fade in.

For the extra characters is easy because you can move them in the room editor, but not the main character.
Title: Re: Cutscene (characters entering, leaving)
Post by: Khris on Wed 01/01/2014 19:25:42
Don't use the ShowPlayerCharacter option if you're planning to show the character eventually.
While you probably can use the undocumented
Code (ags) Select
  player.on = true;you should simply set their .Transparency to 100 in room_Load, then back to 0 when you want to display them.

You can also place a character using any of those:
Code (ags) Select
  player.x = 150; player.y = 130;
  player.ChangeRoom(player.Room, 150, 130), // should work...?
Title: Re: Cutscene (characters entering, leaving) [SOLVED]
Post by: Gabarts on Wed 01/01/2014 21:58:03
Quote
You can also place a character using any of those:
Code (ags) Select
  player.x = 150; player.y = 130;
  player.ChangeRoom(player.Room, 150, 130), // should work...?


Yes, thanks. I can always workaround with Transparency. By the way, now works pretty fine, I'm already finishing the cutscene.