Cutscene (characters entering, leaving) [SOLVED]

Started by Gabarts, Sun 29/12/2013 14:05:15

Previous topic - Next topic

Gabarts

Hi, I'm trying to make this cutscene working but need to clarify some problems...

Check this picture...


And here the code:

Code: ags

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!

Dualnames

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

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();
     }
  }


}

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Gabarts

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!

Gabarts

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
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...

Dualnames

Oh, lol.

eWalkableAreas this on my script needs to be eAnywhere.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

#5
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
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.

Gabarts

Fantastic, thanks Khris! ;-D

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

Crimson Wizard

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.

Gabarts

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...

Dualnames

No offense, but you've clearly didn't even bother with the code I've posted.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Gabarts

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.

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

"Isn't working" is not enough. I found the error though; there was a redundant { at the start of the first function's body.

Gabarts

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

Khris

I don't know about the other thing, but I tested my code and it worked just fine (except for the additional curly bracket).

Gabarts

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! :)

Gabarts

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.

Khris

#17
Don't use the ShowPlayerCharacter option if you're planning to show the character eventually.
While you probably can use the undocumented
Code: ags
  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
  player.x = 150; player.y = 130;
  player.ChangeRoom(player.Room, 150, 130), // should work...?

Gabarts

Quote
You can also place a character using any of those:
Code: ags
  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.

SMF spam blocked by CleanTalk