Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ted Anderson on Wed 19/01/2011 03:53:27

Title: Treating GUI like a background object?
Post by: Ted Anderson on Wed 19/01/2011 03:53:27
Hello! Very, very beginner user here, so this might be an extremely dumb question. I'm working on my very first game, and I've got an idea for a cutscene, but I'm not sure if it's possible.

The game as a whole will use a LucasArts-style interface--nine verbs, inventory, etc. However, in one sequence, I want to have the character walk over this interface, as if it were part of the background. Kind of a fourth-wall-breaking moment. How possible is this? What would I have to do to make it work?

Thanks in advance for the help!
Title: Re: Treating GUI like a background object?
Post by: Squinky on Wed 19/01/2011 04:03:18
I haven't used AGS in forever, but looking around in the help file, perhaps you can set the GUI visibility off and have a background with that GUI on the images and make the walkable area there?

The help file shows a function:

gIconBar.Visible = false;

Just tack something like that in your script? I'm sure there are more specifics to be had in the help file :)

Title: Re: Treating GUI like a background object?
Post by: Gilbert on Wed 19/01/2011 05:07:14
Yeah, you need to do tricks such as what Squinky has suggested. GUIs are always drawn on top of objects, characters and the background so there is no way to do this using the real GUI.
Title: Re: Treating GUI like a background object?
Post by: Ted Anderson on Wed 19/01/2011 13:42:51
Yeah, I figured I might have to do something like that. Of course, the problem is, the player can only have zero or one object in their inventory at the time, otherwise it won't necessarily match the background GUI image, and they'll notice something's wrong...

Thanks for the help! I'll probably have more possibly-dumb questions soon.
Title: Re: Treating GUI like a background object?
Post by: Unai on Wed 19/01/2011 14:10:23
Well, if you know which inventory items he has maybe you can paint the sprites as objects
Title: Re: Treating GUI like a background object?
Post by: Gilbert on Wed 19/01/2011 15:45:34
It may not be that hard to make that sprite reflect the most recent look of the GUI though. Just use DynamicSprite.CreateFromScreenShot() (http://www.adventuregamestudio.co.uk/manual/DynamicSprite.CreateFromScreenShot.htm) to snap the screen just before disabling the GUI and then crop (http://www.adventuregamestudio.co.uk/manual/DynamicSprite.Crop.htm) it to have just the region of the GUI left.
Title: Re: Treating GUI like a background object?
Post by: Ultra Magnus on Wed 19/01/2011 16:10:34
I thought about this for my game, and what I came up with was this.

Replace the character with a GUI button that uses the same base sprite, and then just control the button as you would the character. So, for example something like...


btnDude.SetPosition(cEgo.x, cEgo.y);
btnDude.Visible=true;
cEgo.Transparency=100;
btnDude.Animate(1, 3, eRepeat); // same view and loop as the character's walk cycle;
while (btnDude.X<300) btnDude.X=+1;
btnDude.NormalGraphic=7; // character's standing sprite
cEgo.x=btnDude.X;
cEgo.y=btnDude.Y;
cEgo.Transparency=0;
btnDude.Visibe=false;


...will swap the character for a button (btnDude), make the button walk across the screen (in front of any GUIs that he may come across), and swap it back to the character.



Alternatively, you could try putting bool cutscene; at the top of your script, and then this in the repeatedly_execute section...

if (cutscene=true) {
  btnDude.SetPosition(cEgo.x, cEgo.y);
  btnDude.Visible=true;
  cEgo.Transparency=100;
  if (cEgo.Moving=true) btnDude.Animate(1, 3, eRepeat); // same view and loop as the character's walk cycle;
  else btnDude.NormalGraphic=7; // character's standing sprite
}
else {
  cEgo.Transparency=0;
  btnDude.Visibe=false;
}


...and then you can just use this for the cutscene...

cutscene=true;
cEgo.Walk(300, cEgo.y);
cutscene=false;


...which would make it easier if you want the char to do a lot of moving, as you won't have to duplicate too much of the same code.

Note: I can't test this myself, and it's been a couple of months since I last coded anything, so my script may need a little tweaking to actually work, but it should be close enough to figure out with a little experimenting. Particularly, I have a feeling that btn.Animate won't work in rep_exec, but I can't think of how to get the character's current frame and apply that to btnDude.NormalGraphic. I'm sure someone else can help with this bit, though.
Title: Re: Treating GUI like a background object?
Post by: Khris on Wed 19/01/2011 17:27:08
You can get the current frame using a ViewFrame.

Ted Anderson:
Is this for a static cutscene? In other words, is the GUI supposed to still behave like normal, reacting to buttons and all? Because if it isn't, Gilbet's method is the way to go.

Otherwise I'd go a similar route as Ultra Magnus, it's possible to make the GUI character walk on mouse clicks though.
Basically,
-turn on a walkable area below the GUI
-make the character invisible
-make the GUI character mirror the invisible character below the GUI in rep_ex
Title: Re: Treating GUI like a background object?
Post by: Ted Anderson on Thu 20/01/2011 03:17:50
Quote from: Khris on Wed 19/01/2011 17:27:08
Is this for a static cutscene? In other words, is the GUI supposed to still behave like normal, reacting to buttons and all? Because if it isn't, Gilbet's method is the way to go.

Yeah, it'd be static, so Gilbet's method should work just fine. Thanks, everybody! It's great to have such a responsive and helpful community.