character walks to an object from a gui button

Started by barefoot, Fri 19/11/2010 19:26:09

Previous topic - Next topic

barefoot

Hi

I was wondering if its possible to have main character walk to an object from a gui button click?

EG
When you click 'Walk to Bridge' gui button for example the character walks to the bridge (object)..

Can AGS determine xy for an object and have the char go there?

I have done a search but to no avail...

cheers

barefoot




I May Not Be Perfect but I Have A Big Heart ..

Matti

Quote from: barefoot on Fri 19/11/2010 19:26:09
Can AGS determine xy for an object and have the char go there?

Um, yes.

cEgo.Walk(oObject.X, oObject.Y);

If you had typed "object" in the index search box of the manual, you would've immediately found your answer. Also, there is nothing whose coordinates can't be get. If AGS couldn't handle such simple stuff, I'd switch the engine.

barefoot

Yes, I know about object x y Matti.. 

but i have found various way of going about what im looking for.. but thanks anyway..

barefoot
I May Not Be Perfect but I Have A Big Heart ..

monkey0506

To be totally sure that you understand Matti's response, you can call that command from within the GUI Button's OnClick event handler:

Code: ags
function btnWalk_OnClick(GUIControl *control, MouseButton button)
{
  if (player.Room == 4)
  {
    player.Walk(object[3].X, object[3].Y);
  }
}

barefoot

I May Not Be Perfect but I Have A Big Heart ..

monkey0506

Okay, well I'm glad you got it sorted out. Just the way it came across (to me) was that Matti gave you an answer and you just immediately shot him down saying you know a better way. Ah well.

SMF spam blocked by CleanTalk