Frame loops, animation sequences.
Frame loops, animation sequences.
Ok I'm working on making a fps (just like the rest of us beginners it seems) and I have my gun on the screen. So when I press down on the mouse I would like it to shoot. How would I tell the gun to only play the shooting sequence only once whenever the mouse is pressed?
Re: Frame loops, animation sequences.
i'm not so far like you .
but can you tell me how did you get our weapon on your screen please .
here you've a code to let you weapon schoot with the left mouse button , i just got it from the examples 15. Demo .
but can you tell me how did you get our weapon on your screen please .
here you've a code to let you weapon schoot with the left mouse button , i just got it from the examples 15. Demo .
Code: Select all
bool CDemo::OnEvent(SEvent event)
{
if (!device)
return false;
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_ESCAPE &&
event.KeyInput.PressedDown == false)
{
// user wants to quit.
if (currentScene < 3)
timeForThisScene = 0;
else
device->closeDevice();
}
else
if ((event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_SPACE &&
event.KeyInput.PressedDown == false) ||
(event.EventType == EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) &&
currentScene == 3)
{
// shoot
shoot();
}
else
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_F9 &&
event.KeyInput.PressedDown == false)
{
video::IImage* image = device->getVideoDriver()->createScreenShot();
if (image)
{
device->getVideoDriver()->writeImageToFile(image, "screenshot.bmp");
device->getVideoDriver()->writeImageToFile(image, "screenshot.png");
device->getVideoDriver()->writeImageToFile(image, "screenshot.tga");
device->getVideoDriver()->writeImageToFile(image, "screenshot.ppm");
}
image->drop();
}
else
if (device->getSceneManager()->getActiveCamera())
{
device->getSceneManager()->getActiveCamera()->OnEvent(event);
return true;
}
return false;
}
thanks for the help, but I figured it out...all you had to do to have play only once was setLoopMode(false). As for your question on how I got it on the screen here is my code:0
Hope this answers you question
Code: Select all
//load gun model and texture
scene::IAnimatedMeshSceneNode* gunNode = 0; //define gun node
scene::IAnimatedMesh* gun = smgr->getMesh("glock.obj");//import gun model
if(gun){
gunNode = smgr->addAnimatedMeshSceneNode(gun); //add gun model to screen
camera->addChild(gunNode); //set camera as its parent
gunNode->setPosition(core::vector3df(0,20,-5)); //move it so it looks like its in the right hand
gunNode->setRotation(core::vector3df(0,-90,-90)); //set the rotation
gunNode->setMaterialTexture(0, driver->getTexture("glock.mtl")); //load in the texture (though my gun still seems to stay black)
}
-
- Posts: 616
- Joined: Wed Nov 01, 2006 6:26 pm
- Location: Cairo,Egypt
- Contact: