Flash jump'n'run -> The Adventures of Tinger

A great game and a great article to go with it. Very informative. I hope you don't mind, but I added a link to your article to the 'List of useful articles' Wiki:

http://www.box2d.org/wiki/index.php?title=List_of_useful_articles
@Maroxe

if you have the collission manifold, all you do is:
var normal:b2Vec2 = manifold.normal;
var angle:Number = ( Math.asin ( normal.x / normal.Length () ) / Math.PI * 180);

(Note: this is Actionscript 3 using box2d 1.4)

@Boris: thanks, yes it is a shame, perhaps in a future release of the game I'll try to fix this. I'm a bit short on time atm.

@Pault: No I don't mind at all. Thanks for linking.
thanks huesforalice, but before i read your answer, i proced like that(in c++):
Code:
b2Vec2 n = point->normal;//normal vector
b2Vec2 v(0, 1);   //up vector
float cosAngle = (v.x*n.x+v.y*n.y) / (v.Length() * n.Length());
angle = acosf(cosAngle);
Can't you just take the contact normal and extract the angle from it? The normal points from shape1 to shape2. Just do atan2(normal.y,normal.x).

For multiple contacts i suppose you can just average the angle (average the normals then take angle).
huesforalice wrote:
@Boris: I'd have to check the code again, but I'm pretty sure that I'm only setting the velocity. I also aply a counterforce to gravity as long as he is not moving and touching the ground, so that he doesn't slip down the slopes. About your bug report, the angle that tinger stands in is defined by the normalvector of his collission with ground. So if he stands on the edge of a collissionbox, he'll stand at an angle. I don't really consider this to be a serious bug, but thanks for pointing it out!

i had the same problem, the solution is to update the angle when collision persist, not when it's added(in C++ do it in ContactListener::Persist() not ContactListener::Add() )

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