CCArmature + box2d: armature not updated

Hello,

I am using CCArmature with box2d collision detection. The box2d body is correctly updated (i.e. it rotates) on a collision, however the CCArmature (or CCSprite?) image is not rotated when a collision happens. The code is below.

I have tried adding a bone to the armature, but that doesn’t help.

Cheers
Tom

CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("object.png", "object.plist", "object.ExportJson");
	
_objArmature = CCArmature::create("object");

this->addChild(_objArmature );
_world = world;
this->createBodyAtPosition(position);
this->setPosition(ccp(_body->GetPosition().x*PTM_RATIO, _body->GetPosition().y*PTM_RATIO));

this->scheduleUpdate();

the createBodyAtPosition function is implemented as follows:

GameScrollWorldObjectData* userData = new GameScrollWorldObjectData();
userData->settype(GameScrollWorldObjectData::ENEMY);
userData->setsubType(GameScrollWorldObjectData::ENEMY_OBSTACLE);
userData->setnode(this);

b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
	
bodyDef.gravityScale = 1.0f;
bodyDef.linearDamping = 1.0f;
bodyDef.fixedRotation = false;
bodyDef.position.Set(position.x / PTM_RATIO, position.y / PTM_RATIO);
_body = _world->CreateBody(&bodyDef);

_objArmature->setBody(_body);

b2Filter filter;
filter.categoryBits = 2;
filter.maskBits = 2;
for (b2Fixture* shapes = _objArmature->getBody()->GetFixtureList(); shapes; shapes = shapes->GetNext())
{
	shapes->SetSensor(false);
	shapes->SetDensity(0.5f / CC_CONTENT_SCALE_FACTOR());
	shapes->SetRestitution(0.0f);
	shapes->SetFriction(0.2f);

	shapes->SetFilterData(filter);
}

b2BodyDef joint;
joint.type = b2_staticBody;
joint.position.Set(position.x / PTM_RATIO, position.y / PTM_RATIO * 2);
b2CircleShape circle;
circle.m_radius = 0.5f;
b2FixtureDef fixJoint;
fixJoint.shape = &circle;

b2Body* jointBody = _world->CreateBody(&joint);

jointBody->CreateFixture(&fixJoint);

b2RevoluteJointDef jointDef;

jointDef.Initialize(_body, jointBody, jointBody->GetWorldCenter());

jointDef.maxMotorTorque = 10.0f;

jointDef.motorSpeed = 1.0f;

jointDef.enableMotor = true;

b2RevoluteJoint *RevJoint = (b2RevoluteJoint*)_world->CreateJoint(&jointDef);

_body->ResetMassData();	
_body->SetUserData(userData);
_objArmature->setVisible(true);

Try this:

OnEnter:

auto touchListener = EventListenerTouchOneByOne::create();
	touchListener->onTouchBegan = CC_CALLBACK_2(Game1::touchBegan, this);
	getEventDispatcher()->addEventListenerWithFixedPriority(touchListener, 100);
	schedule(schedule_selector(Game1::tick));

Later:

void Game1::tick(float dt){
	int velocityIterations = 10;
	int positionIterations = 5;

	world->Step(dt, velocityIterations, positionIterations);
	for(auto b=world->GetBodyList(); b; b=b->GetNext()){
		if(b->GetUserData() != NULL){
			auto myActor=(Sprite*) b->GetUserData();
			myActor->setPosition(b->GetPosition().x, b->GetPosition().y);
			myActor->setRotation(-1 * CC_RADIANS_TO_DEGREES(b->GetAngle()));
		}
	}



}

It seems you need to update the sprites manually.