/**
* added by Bruce Yang on 2012.03.09.15.41~
*创建乌鸦~
*/
-(b2Body*) createCrow:(BYObject*)object {
b2Vec2po = object.position;
b2BodyDefbodyDef;
bodyDef.type=b2_dynamicBody;
bodyDef.position.Set(po.x, po.y);
b2Body*body =_single.gameSceneWorld->CreateBody(&bodyDef);
body->SetFixedRotation(true);
/**
*https://love2d.org/wiki/Body:getLinearDamping
* Body:getLinearDamping
* Gets the linear damping(线性阻尼) of the Body.
*The linear damping is the rate of decrease of the linear velocity over time.
*A moving body with no damping and no external forces will continue moving indefinitely,
*as is the case in space. A moving body with damping will gradually stop moving.
*
*Damping is not the same as friction - they can be modelled together.
*However, only damping is provided by Box2D (and LOVE).
*/
/**
* 2012.03.15.11.20, added by Bruce Yang, adviced by Eric Zhu~
*相当的有效啊,乌鸦不再烦人的摆来荡去了~
*/
body->SetLinearDamping(0.8f);
body->m_isCuttable=false;
b2PolygonShapeshape;
shape.SetAsBox(0.4f,0.1f);
b2FixtureDeffixtDef;
fixtDef.shape= &shape;
fixtDef.density=CROW_DENSITY;
fixtDef.friction=CROW_FRICTION;
fixtDef.restitution=CROW_RESTITUTION;
body->CreateFixture(&fixtDef);
BYSpriteCrow*sprite = [BYSpriteCrowspriteWithSpriteFrameName:@"animCrow0.png"];
[spritesetupSchedule];
sprite.position=ccp(po.x*PTM_RATIO, po.y*PTM_RATIO);
sprite.tag=TAG_SPRITE_CROW;
sprite.scale=1.5f;
[[BYSinglegetInstance]spriteRunRepeatAction:spriteanimName:ANIMATION_CACHE_CROW_FLY];
[_single.gameLayeraddChild:spritez:-1];
body->SetUserData(sprite);
returnbody;
}
/**
* added by Bruce Yang on 2012.03.09.15.41~
*创建乌鸦~
*/
-(b2Body*) createCrow:(BYObject*)object {
b2Vec2po = object.position;
b2BodyDefbodyDef;
bodyDef.type=b2_dynamicBody;
bodyDef.position.Set(po.x, po.y);
b2Body*body =_single.gameSceneWorld->CreateBody(&bodyDef);
body->SetFixedRotation(true);
/**
*https://love2d.org/wiki/Body:getLinearDamping
* Body:getLinearDamping
* Gets the linear damping(线性阻尼) of the Body.
*The linear damping is the rate of decrease of the linear velocity over time.
*A moving body with no damping and no external forces will continue moving indefinitely,
*as is the case in space. A moving body with damping will gradually stop moving.
*
*Damping is not the same as friction - they can be modelled together.
*However, only damping is provided by Box2D (and LOVE).
*/
/**
* 2012.03.15.11.20, added by Bruce Yang, adviced by Eric Zhu~
*相当的有效啊,乌鸦不再烦人的摆来荡去了~
*/
body->SetLinearDamping(0.8f);
body->m_isCuttable=false;
b2PolygonShapeshape;
shape.SetAsBox(0.4f,0.1f);
b2FixtureDeffixtDef;
fixtDef.shape= &shape;
fixtDef.density=CROW_DENSITY;
fixtDef.friction=CROW_FRICTION;
fixtDef.restitution=CROW_RESTITUTION;
body->CreateFixture(&fixtDef);
BYSpriteCrow*sprite = [BYSpriteCrowspriteWithSpriteFrameName:@"animCrow0.png"];
[spritesetupSchedule];
sprite.position=ccp(po.x*PTM_RATIO, po.y*PTM_RATIO);
sprite.tag=TAG_SPRITE_CROW;
sprite.scale=1.5f;
[[BYSinglegetInstance]spriteRunRepeatAction:spriteanimName:ANIMATION_CACHE_CROW_FLY];
[_single.gameLayeraddChild:spritez:-1];
body->SetUserData(sprite);
returnbody;
}