Thread: Damn move()
View Single Post
  #4  
Old 01-21-2007, 05:32 PM
konidias konidias is offline
Old Bee
konidias's Avatar
Join Date: Jul 2001
Location: Orlando, FL
Posts: 7,222
konidias will become famous soon enough
Send a message via AIM to konidias
Quote:
Originally Posted by Chandler View Post
HTML Code:
function onCreated()
{
  this.showCharacter();
  
  this.curPlayer = findPlayer("cHANDLER");
  this.onTimeout();
}
function onTimeout()
{
  temp.movex = this.curPlayer.x - x; // x needed to travel to player
  temp.movey = this.curPlayer.y - y; // y needed to travel to player
  dir = getdir(temp.movex, temp.movey);
  
  if (player.dir == 1) { this.desx = 1.7;   this.desy = 1;    }
  if (player.dir == 0) { this.desx = -1.7;  this.desy = 1;    }
  if (player.dir == 2) { this.desx = 1.7;   this.desy = -1.7; }
  if (player.dir == 3) { this.desx = -1.7;  this.desy = -1.7; }
 
  this.ani = "walk";
  move((temp.movex + this.desx), (temp.movey + this.desy), 1, 8+16);
}
function onMovementFinished()
{
  this.ani = "idle";
  this.onTimeout();
}
Like that. The 8 in bold means "inform when done" which lets you use "onMovementFinished". The 16 is for making sure the npc faces the direction it's moving. Otherwise it's just gonna be facing down or whatever while it walks.
__________________

Put this image in your sig if you support Bomy Island! (g2k1 revision)
play bomberman while you wait!


Reply With Quote