SOLVED: when Object x y meets condition then another action happens

Started by barefoot, Wed 09/06/2010 21:24:17

Previous topic - Next topic

barefoot

Hi

Ive used the Object.GetAtScreenXY but to no avail..

I have some Objects with each one set to Int Random Moves.. which works fine..  

Now I need to check when a certain Object moves to one of the int random options it then carry's out an 'if'...

eg:
if Object A moves to x y coordinates then AddInventory.....  etc

Code I have at the moment:
Code: ags

function oyellcirc_Interact()
{
int ran=Random(5);
if (ran==0) object[1].Move(134, 292, 4, eBlock, eAnywhere);
else if (ran==1) object[1].Move(206, 285, 4, eBlock, eAnywhere);
else if (ran==2) object[1].Move(269, 284, 4, eBlock, eAnywhere);
else if (ran==3) object[1].Move(320, 274, 4, eBlock, eAnywhere);
else if (ran==4) object[1].Move(360, 294, 4, eBlock, eAnywhere);
else if (ran==5) object[1].Move(217, 344, 4, eBlock, eAnywhere);
else object[1].Move(146, 298, 4, eBlock, eAnywhere);
}


Hope this is understandable

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

Vince Twelve

You'll want to use
Code: ags

if(object[1].x==360 && object[1].y==294){
 ...
}


GetAtScreenXY is asking for finding out, basically, if you pointed your mouse at these X,Y coordinates, would you be touching an object?  So, if you have transparency in the object's graphic in the lower left corner, GetAtScreenXY wouldn't find it.

But like I showed in that other thread, since the movement is blocking, if you want an action to happen immediately when the object reaches one of the destinations, you can just put the commands in the same block of code:

Code: ags

  if(ran==2){
    oObject.Move(320, 202, 5, eBlock);
    oDoor.Graphic=50; //or whatever code you want to reach after the object reaches this destination
  }


barefoot

Cheers Vince.. brill...

x has to be X

:=

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

SMF spam blocked by CleanTalk