Quote:
Originally Posted by Chandler
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.