Switching between nodes with a keystroke
Posted: Tue Aug 30, 2011 12:59 pm
I have placed two identical nodes on the scene, node1 and node2. I want to be able to alternate between them during runtime at the stroke of a key, and then to trigger the selected node's animations. I have created an additional pointer called "node" that points to one of the two nodes which the user has selected. So, whenever user pushes the S button, a different node is selected and the camera jumps to it, and everything in the while loop is done on the "node" pointer.
And it works with the following code, but it doesn't work perfectly. A lot of the times I have to push the key real hard for it to switch, or multiple times. Could anyone tell me if the problem with the switching is due to my code or is it something that can't be fixed?
And it works with the following code, but it doesn't work perfectly. A lot of the times I have to push the key real hard for it to switch, or multiple times. Could anyone tell me if the problem with the switching is due to my code or is it something that can't be fixed?
Code: Select all
IAnimatedMeshSceneNode* node = node1;
int pom = 1;
//later, in the while(device->run()) loop
if(receiver.IsKeyDown(irr::KEY_KEY_S))
{
if(pom == 1)
{
node = node2;
pom = 2;
cam->setPosition(core::vector3df(60,-10,-10));
cam->setTarget(core::vector3df(70,0,50));
}
else
{
node = node1;
pom = 1;
cam->setPosition(core::vector3df(50,-10,-10));
cam->setTarget(core::vector3df(50,0,50));
}
}