here's a fragment
u32 time1 global
Code: Select all
if(event.EventType == EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP){
time1=device->getTimer()->getTime();
}
Code: Select all
if(event.EventType == EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP){
time1=device->getTimer()->getTime();
}
Code: Select all
IrrlichtDevice* device = 0;
int atstumas;
u32 timetorun,time1;
Code: Select all
vector3df coords; //storage for the player coordinates (node)
if(event.EventType == EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP){
coord=node->getPosition(); atstumas=sqrt((coord.X-intersection.X)*(coord.X-intersection.X)+(coord.Y-intersection.Y)*(coord.Y-intersection.Y));
//atstumas calculates the way between node and his target
timetorun=atstumas*5;
node->setFrameLoop(1, 2500); //set node to run
node->setRotation(faceTarget(intersection,coord));
//rotate node to target anim=smgr->createFlyStraightAnimator(coord,intersection,u32)timetorun,false);
node->addAnimator(anim);
anim->drop();
//animator to walk to the target
time1=device->getTimer()->getTime();
//I use time1 to know when the animation should stop
}
Code: Select all
device =
createDevice( video::EDT_DIRECT3D9, dimension2d<s32>(640, 480), 16,
false, false, false, &receiver);
Code: Select all
if (time1-device->getTimer()->getTime()+timetorun<0)
node->setFrameLoop(1,1);
//after after timetorun we turn the object to standing frame again