本文整理汇总了C++中Convert::CoordPixelsToWorld方法的典型用法代码示例。如果您正苦于以下问题:C++ Convert::CoordPixelsToWorld方法的具体用法?C++ Convert::CoordPixelsToWorld怎么用?C++ Convert::CoordPixelsToWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Convert
的用法示例。
在下文中一共展示了Convert::CoordPixelsToWorld方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Initialize
void Enemy::Initialize(b2World& world, b2Vec2 position) {
bodyDef.position = position;
bodyDef.type = b2_dynamicBody;
bodyDef.fixedRotation = true;
body = world.CreateBody(&bodyDef);
Convert convert;
b2Vec2 vs0, vs1, vs2, vs3;
b2Vec2* vs = new b2Vec2[4];
vs0 = convert.CoordPixelsToWorld(0, 50, 50.0f, 50.0f);
vs1 = convert.CoordPixelsToWorld(0, 0, 50.0f, 50.0f);
vs2 = convert.CoordPixelsToWorld(50, 0, 50.0f, 50.0f);
vs3 = convert.CoordPixelsToWorld(50, 50, 50.0f, 50.0f);
vs[0].Set(vs0.x, vs0.y);
vs[1].Set(vs1.x, vs1.y);
vs[2].Set(vs2.x, vs2.y);
vs[3].Set(vs3.x, vs3.y);
shape.Set(vs, 4);
delete vs;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.0f;
fixtureDef.shape = &shape;
body->CreateFixture(&fixtureDef);
b2Fixture* enemySensorFixture = body->CreateFixture(&fixtureDef);
ContactUserData* cud = new ContactUserData();
cud->type = ContactUserData::Type::ENEMY;
cud->data = this;
enemySensorFixture->SetUserData(cud);
}