Asteroid* Game::SpawnAsteroid(const Vector2& position, const GameSide& side) { // Main ObjectId objId = this->SpawnEntity(); Asteroid* unit = new Asteroid(this, -1); this->addComponent(objId, unit); // Render Component BaseNode* graphic = new BaseNode(kSpriteAsteroid); graphic->setPosition(position.x, position.y); graphic->setScale(0.5f); GFGame::Components::RenderComponent* node = new GFGame::Components::RenderComponent(graphic); this->addComponent(objId, node); // Physics Component GFGame::Components::PhysicsComponent* physics = new GFGame::Components::PhysicsComponent(); b2Body* body = GFort::Core::Physics::PhysicsHelper::CreateCircle( phys_controller_.World(), b2_dynamicBody, position, min(graphic->getContentSize().width, graphic->getContentSize().height) * 0.5 * graphic->getScale()); body->SetFixedRotation(false); body->SetAngularDamping(0); body->SetAngularVelocity(10); // Set the dynamic body fixture. b2Fixture* fixture = body->GetFixtureList(); b2Filter filter = fixture[0].GetFilterData(); filter.categoryBits = kCategoryBitsObstacle; filter.maskBits = kMaskBitsObstacle; fixture[0].SetFilterData(filter); physics->AddBody("root", body); graphic->SetBody(body); this->addComponent(objId, physics); unit->physics_component_ = physics; return unit; //return objId; }