View Single Post
  #7  
Old 03-08-2011, 12:01 AM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
use a timeout and use checks

PHP Code:
function onCreated()
{

  
this.width = <WIDTH>; //In Tiles
  
this.height = <HEIGHT>; //In Tiles
  
onTimeout();

}

function 
onTimeout()
{

  if ( 
player.x + 1.5 in | this.x, this.width| &&
       
player.y + 2.0 in | this.y, this.height| &&
       !
this.touch)
  {

    
this.touch = true;
    
//Touch Actions

  
}

  if ( !( 
player.x + 1.5 in | this.x, this.width|) &&
       !( 
player.y + 2.0 in | this.y, this.height|) &&
       
this.touch)
  {

    
this.touch = false;
    
//Stop Touch Actions

  
}

  
setTimer( 0.1);

} 
replace <WIDTH> and <HEIGHT> with the NPCs width and height in tiles, not pixels. ( 1 pixel would equal ( 1 / 16), btw)
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote