Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: steptoe on Tue 08/05/2012 12:22:13

Title: SOLVED: Player leaping over objects... leaps right but not left properly..
Post by: steptoe on Tue 08/05/2012 12:22:13
Hi

I seem to have run into a slight snag and can't quite see what the problem is.

I have a character that can jump up and grab objects in the air and then drop back down. This is perfect and is set off by a Button: Jump.

I also have a Leap Button that causes the player to Leap over objects.

However, it seems to always leap in one direction: right.

The Jump events do NOT seem to affect the Leap events.

Player Views are ok.

EDIT: This Script seems to work:

function Button2_OnClick(GUIControl *control, MouseButton button)
{
 
  //PLAYER LEAPS
 
   if (cspud.Loop==2 )
   {
 
   cspud.LockView(12);
   cspud.Move(cspud.x+80, cspud.y-60, eBlock, eAnywhere);
   cspud.Move(cspudx-0, cspud.y +60, eBlock, eAnywhere);
   cspud.UnlockView();
   cspud.FaceLocation(640, 374);
   }
   
   else if (cspud.Loop==1)
   {
   cspud.LockView(12);
   cspud.Move(cspud.x-80, cspud.y-60, eBlock, eAnywhere);
   cspud.Move(cspud.x-0, cspud.y +60, eBlock, eAnywhere);
   cspud.UnlockView();
   cspud.FaceLocation(0, 374);
   
   }
   
   else if (cspud.Loop==0)
   {
   cspud.LockView(12);
   cspud.Move(cspud.x-0, cspud.y-60, eBlock, eAnywhere);
   cspud.Move(ccspud.x-0, cspud.y +60, eBlock, eAnywhere);
   cspud.UnlockView();
   
   }
   }
   


OLD CODE:


function Button2_OnClick(GUIControl *control, MouseButton button)
{
 
  //PLAYER LEAPS
 
   if (cspud.FaceLocation(640, 370))
   {

    cspud.LockView(12);
    cspud.Move(cspud.x+80, cspud.y-60, eBlock, eAnywhere);
    cspud.Move(cspud.x-0,  cspud.y +60, eBlock, eAnywhere);
    cspud.UnlockView();
 
   }
   
   else if (cspud.FaceLocation(0, 370))
   {
   
   cspud.LockView(12);
   cspud.Move(cspud.x-80, cspud.y-60, eBlock, eAnywhere);
   cspud.Move(cspud.x-0,  cspud.y +60, eBlock, eAnywhere);
   cspud.UnlockView();
   
   }
   }


Can if you can spot where the problem/error may be or something I have overlooked?

Cheers
Title: Re: Player leaping over objects... leaps right but not left properly..
Post by: Gilbert on Tue 08/05/2012 14:48:59
Simple. "if (Character.FaceLocation())..." will NOT work.

FaceLocation() is to make the character face the specified location, not checking which direction he is facing. Just check the loop like your own fix instead.
Title: Re: Player leaping over objects... leaps right but not left properly..
Post by: steptoe on Tue 08/05/2012 16:12:13
Iceboty,

Went with player loop. Works fine.

cheers