i am having problems with keyboard input
i like to have when i press the R button that a animation shows 1 time not looping
i have searched for it but realy can't find it
here is my (error giving) code(i know its wrong but this is the closest that i can come to let you know what i want)
Code: Select all
main code
#include <irrlicht.h>
#include <iostream>
#include <irrKlang.h>
#include <ILightSceneNode.h>
#include <ISceneNode.h>
#include <stdio.h>
#include <wchar.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace irrklang;
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "irrKlang.lib")
scene::ISceneNode* g = 0;
IrrlichtDevice* device = 0;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (g != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT &&
!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_R:
{
gun->setFrameLoop(0,100);
}
return true;
}
}
return false;
}
};
int main(int argc, const char** argv)
{
MyEventReceiver receiver;
device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480),
32, false, true, false, &receiver);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
// start the sound engine
ISoundEngine* engine = createIrrKlangDevice();
if (!engine)
return 0; // error starting up the engine
IrrlichtDevice *device =
createDevice(EDT_OPENGL, dimension2d<s32>(1024,768), 32,
false, true, false, &receiver);
MY GUN
//test: object added to camera
IAnimatedMesh* gun = smgr->getMesh("assault.X");
IAnimatedMeshSceneNode* g = smgr->addAnimatedMeshSceneNode( gun );
if(g)
{
g->setMaterialFlag(EMF_LIGHTING, true);
g->setPosition(core::vector3df(1.0,-1.6,3.35));
//g->setPosition(core::vector3df(0.7,-1.4,3.35));
g->setRotation(core::vector3df(90,0,180));
g->setScale(core::vector3df(3,3,3));
//g->setScale(core::vector3df(2,2,2));
g->setParent(camera);
}


