Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - JCSopko

Pages: 1 [2]
16
Window / Execute Code on Key Release?
« on: June 30, 2010, 09:22:41 pm »
I think I understand, but I have work so I don't have time to be sure or try to implement it, I'll try when I get back. Currently my code for momvement is as follows:

Code: [Select]
if(Game.GetInput().IsKeyDown(sf::Key::A))
{
if(myBox.body->GetLinearVelocity().x > 0)
{
myBox.yVel = myBox.body->GetLinearVelocity().y;
myBox.body->SetLinearVelocity(b2Vec2(0,myBox.yVel));
}

myBox.body->ApplyForce(b2Vec2(-75, 0), b2Vec2(myBox.position.x, myBox.position.y));
}


and that along with other input is in the game loop. so If i put the first example you showed me along with this code in the while loop it should stop all movement on the key release correct?

Thanks for all the help by the way, sorry this post is a little vague and rushed.

Joe

17
Window / Execute Code on Key Release?
« on: June 30, 2010, 07:34:05 pm »
Yeah I've read through the tutorial and searched through the documentation but have been unable to find exactly what I'm looking for.

I'm using Box2D and am applying a force on key presses but I would like the linear velocity to be set to 0 when the key is released so the player is only moving when the key is held down.

Does SFML allow for this or is there a workaround?

Thanks,
Joe

18
Window / Execute Code on Key Release?
« on: June 30, 2010, 06:58:49 pm »
My bad, poor wording on my part, a few lines of code like setting a velocity variable to zero. So just replace a string of code with code, sorry for the confusion =]

19
Window / Execute Code on Key Release?
« on: June 30, 2010, 05:54:03 pm »
I've been looking around the forums and the documentation but have been unable to find a way to execute a string of code on the release of a key press with SFML 1.6. Can someone help me out or point me in the right direction? Thanks.

Regards,
Joe

Pages: 1 [2]
anything