2 problems using box2d making a platform game.

Hey at the moment I'm creating a platforming game with box2d and I've run into some problems.

My character movement is implemented like (pseudo-code):
Code:
void onUpdate()
{
if (rightButtonIsDown)
    character->SetVelocity(b2Vec2(2.0f, 0.0f));
else if (leftButtonIsDown)
    character->setVelocity(b2Vec2(-2.0f, 0.0f));
else
    character->SetVelocity(b2Vec2(0.0f, character->GetVelocity().y));
}

void onUpPressed()
{
    if (canJump == true)
        character->ApplyImpulse(b2Vec2(0.0f, 10.0f));
}
(the character shape is a circle)

[/cut] I solved the first problem on my own 🙂

The second problem: when the character moves up a slope (a angled rectangle shape) and then suddenly stops, it wil jump up a little bit. I think the reason is that the character penetrates the slope when it moves, then shoots up to get out again when it stops.

Both of these behaviours are undesired in my game, is there anyway to stop those from happening? I'm also open for suggestions for other implementations for the movement system.

Thanks in advance.

ps: Sorry for my somewhat slacky english, hopefully I made myself clear.
It seems quite unnatural to set the vertical velocity to zero when moving. Perhaps you could leave it as the current y-velocity as you do for the last case when the player is not moving. I think this would help to stop it penetrating the ground so much.
If your problem hasn't been solved yet, it could be that you're setting the velocity directly. After many tutorials about Box2D, I've heard many people stating that directly setting the linear velocity of an object is a bad thing to do as it can mess up with the simulation. One of the places that I remembered seeing that was in the tutorial:
http://www.raywenderlich.com/475/how-to-create-a-simple-breakout-game-with-box2d-and-cocos2d-tutorial-part-12

near the bottom of that tutorial where people commented, you will see people discussing it.
One of the solutions(instead of setting the velocity directly) was to apply a force, and then give it some damping to slow it right down.

Hope that helps!

Original thread: https://box2d.org/forum/viewtopic.php?t=7496