Treating GUI like a background object?

Started by Ted Anderson, Wed 19/01/2011 03:53:27

Previous topic - Next topic

Ted Anderson

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!

Squinky

#1
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 :)


Gilbert

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.

Ted Anderson

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.

Unai

Well, if you know which inventory items he has maybe you can paint the sprites as objects
I am a deeply superficial person

Gilbert

It may not be that hard to make that sprite reflect the most recent look of the GUI though. Just use DynamicSprite.CreateFromScreenShot() to snap the screen just before disabling the GUI and then crop it to have just the region of the GUI left.

Ultra Magnus

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

Code: ags

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...
Code: ags

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...
Code: ags

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.
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

Khris

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

Ted Anderson

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.

SMF spam blocked by CleanTalk