there is a delay in key presses, i have tried 2 different things the first one was using an input and getting a bool for the key pressed
void Player::Move(const sf::Input &input)
{
if( input.IsKeyDown( sf::Key::Up ))
{
m_yVel -= m_speed;
Animate();
}
else if(input.IsKeyDown( sf::Key::Down ))
{
m_yVel += m_speed;
Animate();
}
else if(input.IsKeyDown( sf::Key::Left ))
{
m_xVel -= m_speed;
Animate();
}
else if(input.IsKeyDown( sf::Key::Right ))
{
m_xVel += m_speed;
Animate();
}
if( input.IsKeyDown( sf::Key::A ))
weapon->Add(new Knife(m_x, m_y));
}
then i tried to do the switch statement taking an event
if(Event.Type == sf::Event::KeyPressed)
{
switch(Event.Key.Code){
case sf::Key::Up:
m_yVel -= m_speed;
Animate();
break;
case sf::Key::Down:
m_yVel += m_speed;
Animate();
break;
case sf::Key::Right:
m_xVel += m_speed;
Animate();
break;
case sf::Key::Left:
m_xVel -= m_speed;
Animate();
break;
default:
break;
}
}
if(Event.Type == sf::Event::KeyReleased)
{
switch(Event.Key.Code){
case sf::Key::Right:
m_xVel = 0;
break;
case sf::Key::Left:
m_xVel = 0;
break;
case sf::Key::Up:
m_yVel = 0;
break;
case sf::Key::Down:
m_yVel = 0;
break;
default:
break;
}
}
}
ps the first one i decrease the accel in the main eventhandling function
There is only a delay when you switch form left to right or up to down with out releasing the previous button first and it is like a 1/2 sec delay and if any of my friends play i dont want them complaining so HELP!!