if I press A, S or Escape, the events will be executed else nothing happens. Why ? Another Question: How is it possible to move the Model by one pressing very far ? By this code I must press to much on one of the Keys.
Code: Select all
virtual bool OnEvent(SEvent event)
{
if (node != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT&&
!event.KeyInput.PressedDown)
{
r = node->getRotation();
p = node->getPosition();
float speed = 4.0;
core::vector3df v = node->getPosition();
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
device->closeDevice();
case KEY_KEY_W:
{
v.X = v.X + ( cos(r.Y * 3.14159265/180)* speed);
v.Z = v.Z - ( sin(r.Y * 3.14159265/180)* speed);
node->setPosition(v);
}
case KEY_KEY_S:
{
v.X = v.X - ( cos(r.Y * 3.14159265/180)* speed);
v.Z = v.Z + ( sin(r.Y * 3.14159265/180)* speed);
node->setPosition(v);
} //<--
case KEY_KEY_A:
{
v.X = v.X + ( cos((r.Y-90) * 3.14159265/180)*speed );
v.Z = v.Z - ( sin((r.Y-90) * 3.14159265/180)*speed );
node->setPosition(v);
} //<--
case KEY_KEY_D:
{
v.X = v.X + ( cos((r.Y+90) * 3.14159265/180)*speed );
v.Z = v.Z - ( sin((r.Y+90) * 3.14159265/180)*speed );
node->setPosition(v);
}
return true;
}
}
return false;
}