How do i add a video intro at the beginning of my game?

Started by d1mpz, Fri 25/05/2012 14:29:55

Previous topic - Next topic

d1mpz

I am an extremely new user to AGS. I am creating a point and click adventure game for my college assignment. I have done all my design work and am now about to start creating my game. How do I add a video intro for the game.

Ghost

Use the PlayVideo command: PlayVideo (string filename, VideoSkipStyle, int flags)

It's fully documented in the manual, and you can call it from the game's starting room's "after_fadein" event.

AGS supports quite a lot of video formats too, and for an assignment I think download size isn't a factor, but keep in mind that fullscreen videos can blow up file size easily (without an impact on performance, though).

Best of luck with the project, by the way! Always cool to see AGS used in college projects!


d1mpz

Thank you for your fast reply. However i have tried the playVideo command but i still keep getting errors. I have looked through the manual and it does not specify where to paste the code. I have tried directly at the beginning of the room script and the error below is all i keep receiving.

Failed to save room room1.crm; details below
room1.asc(3): Error (line 3): Parse error: unexpected 'PlayVideo'


Ghost

I see. Have you just typed that line into the script? If yes, then this does not work. You need to set up an event handler, like this:

- open the room ("edit room") and click on that small "flash" button in the bottom right panel.
- click on "enter room after fadein" to create the event handler

Now, in the room script, you have the following code:

function room_AfterFadeIn()
{
}

Add the command between the brackets- this is how you set up a code handler in AGS.

Note: Whenever you want AGS to process code depending on "engine events" (like clicking on something, entering a room, or using an item on something else) you need to set up an event handler!

d1mpz

Thanks very much, problem fixed. I had  the avi file in the wrong place and was missing small bits of coding.

function room_AfterFadeIn() {
  PlayVideo("testing.avi", eVideoSkipEscKey, 0);
}

Guybrush379

#5
I'm trying to loading the intro to my game, I've set all like above (put the file in the game folder with ogg extension).
Black screen and then starts room_2

The only code is this or I need to change something else?
Code: AGS
function room_AfterFadeIn()
{
PlayVideo("Indy_Intro.ogg",eVideoSkipNotAllowed, 0);
}


Guybrush379

Well, after some tries I managed to start the video :)

-Converted in ogv
-Put in game folder as "Intro"
-Setting the code with "Intro.ogv"

Now I ask: I need a new blank room to load properly? Because if I load it in the main first room seems not working properly...

Khris

If you uncheck "hide known file extensions" in Windows' folder settings, you'll always see the complete filename.

What does "seems not working properly" mean? We can't read your mind nor see what's happening on your screen.

Guybrush379

Basically what I want to do is this:

Loading the video (and this works), but when it loads the GUI and the player appears for 1 second and then the video loads. I want to turn off the GUI and the player and then after video has played start my other script for that room.

Khris

In the room's before fadein event (function room_Load), call

Code: ags
  gMaingui.Visible = false;  // replace gMaingui with whatever your GUI is called
  player.Transparency = 100;


Set the values back to true/0 after the PlayVideo call.

Guybrush379

Thanks! your help is much appreciated, i don't know why there is no music along with intro video but i will try to solve...

Guybrush379

To be clear once for all, here what happens when the game starts:



And here is my code:

Code: AGS
function room_FirstLoad()
{

 PlayVideo("Intro.ogv",eVideoSkipEscKey, 0);
 
 gAction.Visible = false;
 gMaingui.Visible = false;
 cEgo.Transparency = 100;
 
 player.ChangeRoom(1, 185, 91);
}


Even if I've set that code the GUI still appears for just a second and then video starts. And the intro plays without music.

arj0n

Quote from: Guybrush379 on Wed 06/06/2012 14:42:58
Even if I've set that code the GUI still appears for just a second and then video starts. And the intro plays without music.
Why first the playvideo command followed by the gui's and character commands?
Shouldn't that be the other way around?

b.t.w. Can you send me/upload the video file so I can analyse it?

Guybrush379

Quote
Why first the playvideo command followed by the gui's and character commands?
Shouldn't that be the other way around?

It doesn't change at all, even if I use After Room fade in and put the right way I still got the 1 second GUI + action showing before video. The video is fine if I launch with VLC...

Khris

Like I said in my previous post, turn off the GUI and character in the room_Load function, which is associated with a different event, before fadein.

After you've clicked the ...-Button next to "enters room before fadein" and the function is created, the script should look like this:

Code: ags
function room_Load()
{
  // this code is executed while the screen is still black
  gAction.Visible = false;
  gMaingui.Visible = false;
  cEgo.Transparency = 100;
}

function room_FirstLoad()
{
  // this is executed after AGS has faded in the room
  PlayVideo("Intro.ogv",eVideoSkipEscKey, 0);
  player.ChangeRoom(1, 185, 91);
}


(The order of the functions doesn't matter.)

Guybrush379

The audio now works fine (I've switched from office pc to my home pc but I think was a problem of ogg compression, now I have avi and it works).

Now the properties are more clear and when use them but unfortunately I still got that 1 second GUI before my video... :(

Khris

It could be that AGS doesn't start faded out at the very beginning...
In that case, set both GUIs' visibility to "Normal, initially off" and change the player character's y starting position to -1

Guybrush379

YES YES!! :) I've finally solved it! Damn, if you leave some values or even a string in bad position is such going madly thing!

Khris forget about the file I've sent you (it even contains scurrile bad language in italian in the library room! :)

I've created a new blank room with the proper value for starting the video and then changeRoom value
Now works very good as I wanted! I'm happy :)

SMF spam blocked by CleanTalk