这篇教程C++ CC_DEGREES_TO_RADIANS函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CC_DEGREES_TO_RADIANS函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_DEGREES_TO_RADIANS函数的具体用法?C++ CC_DEGREES_TO_RADIANS怎么用?C++ CC_DEGREES_TO_RADIANS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CC_DEGREES_TO_RADIANS函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: cpBodySetAnglevoid CCPhysicsSprite::setRotation(float fRotation){ if (m_bIgnoreBodyRotation) { CCSprite::setRotation(fRotation); } else { cpBodySetAngle(m_pCPBody, -CC_DEGREES_TO_RADIANS(fRotation)); }}
开发者ID:AaronlAvaf,项目名称:Nextpeer-UFORUN,代码行数:11,
示例2: cc_to_b2Vecvoid GearButton::createBody(){ b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody; bodyDef.position = cc_to_b2Vec(getParent()->convertToWorldSpace(getPosition()).x, getParent()->convertToWorldSpace(getPosition()).y); bodyDef.angle = -CC_DEGREES_TO_RADIANS(getRotation()); bodyDef.userData = this; _body = GameManager::getInstance()->getBox2dWorld()->CreateBody(&bodyDef); ((LayerItem*)getParent()->getUserObject())->_fixturesCache->addFixturesToBody(_body, "GearButton"); }
开发者ID:linger2334,项目名称:Grow,代码行数:12,
示例3: getRotation void BlockHouse::fireBullet() { float rotation = getRotation(); float angleInRad = -CC_DEGREES_TO_RADIANS(rotation); Vec2 realFirePoint = firePoint.rotateByAngle(Vec2::ZERO, angleInRad); Vec2 dir = target - realFirePoint; Bullet *bullet = Bullet::createWithDirection(dir); bullet->setPosition(realFirePoint); static_cast<GamePlayScene *>(getParent())->addBullet(bullet); }
开发者ID:cppbug,项目名称:untouchable,代码行数:12,
示例4: ccp//label 描边void LabelUtils::createStroke(CCLabelTTF *label, float size, ccColor3B color){ CCSize originalSize = label->getTexture()->getContentSize(); float wid = originalSize.width + size * 2; float hei = originalSize.height + size * 2; CCPoint originalPos = label->getPosition(); CCPoint originalAnchor = label->getAnchorPoint(); ccColor3B originalColor = label->getColor(); ccBlendFunc originalBlend = label->getBlendFunc(); CCNode* node = label->getChildByTag(TAG_STROKE); CCRenderTexture* rt = NULL; if(node) { rt = dynamic_cast<CCRenderTexture*>(node); if(rt) {// rt->clear(0, 0, 0, 0); //这里有问题,会有一个黑色块// CCLOG("use pre-existing CCrenderTexture!"); rt->removeFromParentAndCleanup(true); rt = NULL; } } if(!rt) { rt = CCRenderTexture::create(wid, hei); } label->setColor(color); label->setBlendFunc((ccBlendFunc) { GL_SRC_ALPHA, GL_ONE }); // rt->setAnchorPoint(originalAnchor); //没用 CCPoint center = ccp(wid * originalAnchor.x, hei * originalAnchor.y); rt->beginWithClear(0, 0, 0, 0); for(int i=0; i<360; i+= 15) { float radians = CC_DEGREES_TO_RADIANS(i); label->cocos2d::CCNode::setPosition(center.x + sin(radians)*size, center.y + cos(radians)*size); label->visit(); } rt->end(); label->setPosition(originalPos); label->setColor(originalColor); label->setBlendFunc(originalBlend); float rtX = originalSize.width / 2 + size; float rtY = originalSize.height / 2 - size; rt->setPosition(rtX, rtY); if(rt->getParent() == NULL) label->addChild(rt, -100, TAG_STROKE); //测试 // CCLayerColor* layer = CCLayerColor::create(ccc4(0, 0, 0, 128), wid, hei); // layer->setPosition(rt->getPosition()); // label->addChild(layer);}
开发者ID:qingzhizhu,项目名称:QingLibCocos2dx,代码行数:54,
示例5: sinvoid TransformHelp::nodeToMatrix(const BaseData &node, Mat4 &matrix){ matrix = Mat4::IDENTITY; /// TODO: fix, translate macros, node.skewX stored as degrees? /// check whether 3.10 store node.skewX as radians if (node.skewX == -node.skewY) { double sine = sin(CC_DEGREES_TO_RADIANS(node.skewX)); double cosine = cos(CC_DEGREES_TO_RADIANS(node.skewX)); matrix.m[0] = node.scaleX * cosine; matrix.m[1] = node.scaleX * -sine; matrix.m[4] = node.scaleY * sine; matrix.m[5] = node.scaleY * cosine; } else { matrix.m[0] = node.scaleX * cos(CC_DEGREES_TO_RADIANS(node.skewY)); matrix.m[1] = node.scaleX * sin(CC_DEGREES_TO_RADIANS(node.skewY)); matrix.m[4] = node.scaleY * sin(CC_DEGREES_TO_RADIANS(node.skewX)); matrix.m[5] = node.scaleY * cos(CC_DEGREES_TO_RADIANS(node.skewX)); } matrix.m[12] = node.x; matrix.m[13] = node.y;}
开发者ID:Jian0326,项目名称:cocos2d-x-pc-port,代码行数:26,
示例6: Vec3void HelloWorld::myupdate(float dt){ camera->setPosition3D(car_cabine->getPosition3D() + Vec3(100.0f * sinf(_angle), 30.0f, 100.0f * cosf(_angle))); camera->lookAt(car_cabine->getPosition3D(), Vec3(0.0f, 1.0f, 0.0f)); if (_hud->movingleft == true){ constraint5->setLimit(CC_DEGREES_TO_RADIANS(-20), CC_DEGREES_TO_RADIANS(0)); physics_rbd_wheel_bar->setAngularVelocity(Vec3(0.0, 1.0, 0.0)); //physics_rbd_wheel_bar->setAngularFactor(Vec3(0.0, 0.0, 0.0)); } if (_hud->movingright == true){ constraint5->setLimit(CC_DEGREES_TO_RADIANS(0), CC_DEGREES_TO_RADIANS(20)); physics_rbd_wheel_bar->setAngularVelocity(Vec3(0.0, -1.0, 0.0)); //physics_rbd_wheel_bar->setAngularFactor(Vec3(0.0, 0.0, 0.0)); } if (_hud->movingup == true){ constraint5->setLimit(CC_DEGREES_TO_RADIANS(-0.5), CC_DEGREES_TO_RADIANS(0.5)); Vec3 mynearP((int)wheel1->getPosition3D().x, 0.0, (int)wheel1->getPosition3D().z), myfarP((int)wheel3->getPosition3D().x, 0.0, (int)wheel3->getPosition3D().z); Vec3 mynearP2((int)wheel2->getPosition3D().x, 0.0, (int)wheel2->getPosition3D().z), myfarP2((int)wheel4->getPosition3D().x, 0.0, (int)wheel4->getPosition3D().z); Vec3 mydir(myfarP - mynearP); Vec3 mydir2(myfarP2 - mynearP2); Vec3 mylinearVel = (mydir+mydir2)/2; mylinearVel.normalize(); mylinearVel *= 50.0f; mylinearVel.y = 0; physics_rbd_wheel3->setLinearVelocity(mylinearVel); physics_rbd_wheel4->setLinearVelocity(mylinearVel); }}
开发者ID:dex36,项目名称:Cocos2d-x,代码行数:30,
示例7: CCASSERTnav::Triangle DelaunayAlgorithm::calculateTriangleByCircle(const nav::Circle&circle){ CCASSERT(circle.getR() > 0, "create traingle that circle's r must > 0"); float length = circle.getR() * 2.0f; float d = 90.0f; float r = CC_DEGREES_TO_RADIANS(d); cocos2d::Point a(length, 0); a.rotate(cocos2d::Point(0, 0), r); a = a + circle.getCenter(); d = 90.0f + 120.0f; r = CC_DEGREES_TO_RADIANS(d); cocos2d::Point b(length, 0); b.rotate(cocos2d::Point(0, 0), r); b = b + circle.getCenter(); d = 90.0f + 240.f; r = CC_DEGREES_TO_RADIANS(d); cocos2d::Point c(length, 0); c.rotate(cocos2d::Point(0, 0), r); c = c + circle.getCenter(); nav::Triangle triangle(a, c, b); return triangle;}
开发者ID:spzktshow,项目名称:BigDipper,代码行数:22,
示例8: CC_DEGREES_TO_RADIANSvoid B2Sprite::setRotation(float fRotation){ if (m_bIgnoreBodyRotation) { CCSprite::setRotation(fRotation); } else { b2Vec2 p = m_pB2Body->GetPosition(); float radians = CC_DEGREES_TO_RADIANS(fRotation); m_pB2Body->SetTransform(p, radians); }}
开发者ID:Janak-Nirmal,项目名称:FlappyBirdDemo,代码行数:13,
示例9: CC_DEGREES_TO_RADIANSvoid Sprite3DLesson5::update(float delta){ static float accAngle = 0.f; accAngle += delta * CC_DEGREES_TO_RADIANS(60); Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); float radius = 50.f; Vec3 center(visibleSize.width / 2.f + origin.x, visibleSize.height / 4.f + origin.y, 0); float x = cosf(accAngle) * radius + center.x, z = sinf(accAngle) * radius + center.z; _sprite->setPosition3D(Vec3(x, center.y, z));}
开发者ID:super626,项目名称:LessonDemo,代码行数:13,
示例10: CC_DEGREES_TO_RADIANSvoid CSSceneSkyBoxTest::onTouchesMoved(const std::vector<Touch*>& touches, cocos2d::Event *event){ if (touches.size()) { auto touch = touches[0]; auto delta = touch->getDelta(); static float _angle = 0.f; _angle -= CC_DEGREES_TO_RADIANS(delta.x); _camera->setPosition3D(Vec3(50.0f * sinf(_angle), 0.0f, 50.0f * cosf(_angle))); _camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)); }}
开发者ID:asuo1986,项目名称:own,代码行数:13,
示例11: absvoid CFmBall::StickMove(int aX){ int t; int tx = -sin(CC_DEGREES_TO_RADIANS(m_nAngle))*m_nSpeed; if (tx == 0) return; if (m_pPos->GetX() > aX) { if (m_pPos->GetX() + tx > aX) return; } else { if (m_pPos->GetX() + tx < aX) return; } t = abs(((aX-m_pPos->GetX())/100) / tx); *m_pPos = *m_pPos + FmP3D(-sin(CC_DEGREES_TO_RADIANS(m_nAngle))*m_nSpeed*t, cos(CC_DEGREES_TO_RADIANS(m_nAngle))*m_nSpeed*t, m_nSpeedZ*t)/100;}
开发者ID:louis2001,项目名称:FMTeamTest,代码行数:22,
示例12: CC_DEGREES_TO_RADIANSvoid Platform::initPlatform(int width, float angle, CCPoint position) { //Define shape b2PolygonShape box; box.SetAsBox(width * 0.5f /PTM_RATIO, PLATFORM_HEIGHT * 0.5f / PTM_RATIO); //Define fixture b2FixtureDef fixtureDef; fixtureDef.shape = &box; fixtureDef.density = 1; fixtureDef.restitution = 0; //reutilize body from the pool: so destroy any existent fixture if (_body->GetFixtureList()) { _body->DestroyFixture(_body->GetFixtureList()); } _body->CreateFixture(&fixtureDef); _body->SetTransform(b2Vec2(position.x / PTM_RATIO, position.y / PTM_RATIO), CC_DEGREES_TO_RADIANS(-angle)); _body->SetActive(true); CCSprite * block; float startX = -width * 0.5f + TILE * 0.5f; //set unused tiles in the platform invisible for (int i = 0; i < TILES_PER_PLATFORM; i++) { block = (CCSprite *) _tiles->objectAtIndex(i); if (i >= width/TILE) { block->setVisible(false); } else { block->setVisible(true); block->setPosition(ccp(startX + i * TILE, 0)); block->setFlipY(false); block->setFlipX(false); if (angle == 0.0) { if (position.y >= TILE * 13) block->setFlipY(true); } if (angle == 90.0) { if (position.x > TILE * 5) block->setFlipY(true); } } } switchTexture(); this->setRotation(angle); this->setPosition(position); setVisible(true);}
开发者ID:pdpdds,项目名称:cocos2dx-dev,代码行数:51,
示例13: getShootParamsTank::ExecResult Tank::executeAim(Vec2 p){ if (surfaceId) { if (Planet* planet = _game->objs()->getByIdAs<Planet>(surfaceId)) { Vec2 fromPoint; Vec2 sourceDir; getShootParams(fromPoint, sourceDir); Vec2 targetDir = (p - getShootCenter()).getNormalized(); if (targetDir.isSmall() || sourceDir.isSmall()) { gunRotationSpeed(0.0f); return ExecResult::Done; // We do not know where to aim, so we are done } float aDist = angleDistance(sourceDir.getAngle(), targetDir.getAngle()); if (fabsf(aDist) < CC_DEGREES_TO_RADIANS(5)) { if (fabsf(aDist) < CC_DEGREES_TO_RADIANS(0.2)) { gunRotationSpeed(0.0f); return ExecResult::Done; } else if (aDist < 0) { gunRotationSpeed(-0.1f); return ExecResult::InProgress; } else { gunRotationSpeed(0.1f); return ExecResult::InProgress; } } else if (aDist < 0) { gunRotationSpeed(-1.0f); return ExecResult::InProgress; } else { gunRotationSpeed(1.0f); return ExecResult::InProgress; } } else { return ExecResult::Failed; } } else { return ExecResult::Delayed; }}
开发者ID:bladez-fate,项目名称:bladez,代码行数:38,
示例14: clearvoid Star::drawStar(float radiusOut, float radiusIn){ clear(); ensureCapacity(50); float tempAngle = 360/6; int vIndex = 0; for (float angle = 0; angle < 360; angle += tempAngle) { Vec3 p0 = Vec3(0.0f,0.0f,0.0f); Vec3 p1; p1.x = radiusOut * cosf(CC_DEGREES_TO_RADIANS(angle)); p1.y = radiusOut * sinf(CC_DEGREES_TO_RADIANS(angle)); p1.z = 0.0f; Vec3 p2; p2.x = radiusIn * cosf(CC_DEGREES_TO_RADIANS(angle+tempAngle/2)); p2.y = radiusIn * sinf(CC_DEGREES_TO_RADIANS(angle+tempAngle/2)); p2.z = 0.0f; Vec3 p3 = Vec3(0.0f,0.0f,0.0f); Vec3 p4; p4.x = radiusIn * cosf(CC_DEGREES_TO_RADIANS(angle+tempAngle/2)); p4.y = radiusIn * sinf(CC_DEGREES_TO_RADIANS(angle+tempAngle/2)); p4.z = 0.0f; Vec3 p5; p5.x = radiusOut * cosf(CC_DEGREES_TO_RADIANS(angle+tempAngle)); p5.y = radiusOut * sinf(CC_DEGREES_TO_RADIANS(angle+tempAngle)); p5.z = 0.0f; _buffer[vIndex*6+0] = {p0, Color4B(255, 255, 255, 255)}; _buffer[vIndex*6+1] = {p1, Color4B(255, 0, 0, 255)}; _buffer[vIndex*6+2] = {p2, Color4B(0, 255, 0, 255)}; _buffer[vIndex*6+3] = {p3, Color4B(255, 255, 255, 255)}; _buffer[vIndex*6+4] = {p4, Color4B(0, 255, 0, 255)}; _buffer[vIndex*6+5] = {p5, Color4B(255, 0, 0, 255)}; vIndex++; } _bufferCount += vIndex*6; _dirty = true;}
开发者ID:fordream,项目名称:TestOpenGL,代码行数:48,
示例15: CCRANDOM_MINUS1_1void TestParticleSystem::paint(){ if (!printed) { printed = true; } for (int i = particles.size() -1; i >= 0; i--) { TestParticle* particle = particles.at(i); particle->rotation += CCRANDOM_MINUS1_1(); // Transform float c = cosf(CC_DEGREES_TO_RADIANS(particle->rotation)); float s = sinf(CC_DEGREES_TO_RADIANS(particle->rotation)); // Create transformation matrix for scale, position and rotation Mat4 matrix = Mat4(c * particle->size, s * particle->size, 0.0, 0.0, -s * particle->size, c * particle->size, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, particle->pos.x, particle->pos.y, 0.0, 1.0); particle->transform.multiply(matrix); }}
开发者ID:vlidholt,项目名称:Test,代码行数:23,
示例16: cpvforangle// returns the transform matrix according the Chipmunk Body valuesCCAffineTransform CCPhysicsSprite::nodeToParentTransform(){ cpVect rot = (m_bIgnoreBodyRotation ? cpvforangle(-CC_DEGREES_TO_RADIANS(m_fRotationX)) : m_pCPBody->rot); float x = m_pCPBody->p.x + rot.x*(-m_obAnchorPointInPoints.x) - rot.y*(-m_obAnchorPointInPoints.y); float y = m_pCPBody->p.y + rot.y*(-m_obAnchorPointInPoints.x) + rot.x*(-m_obAnchorPointInPoints.y); if (m_bIgnoreAnchorPointForPosition) { x += m_obAnchorPointInPoints.x; y += m_obAnchorPointInPoints.y; } return (m_sTransform = CCAffineTransformMake(rot.x, rot.y, -rot.y, rot.x, x, y));}
开发者ID:wanggan768q,项目名称:GameWork,代码行数:15,
示例17: KDvoid Level1Scene::ccTouchesEnded ( CCSet* touches, CCEvent* events ){ CCTouch* touch = ( CCTouch* ) ( touches->anyObject ( ) ); CCPoint location = this->convertTouchToNodeSpace ( touch ); if ( m_pMouseJoint != KD_NULL ) { if ( m_pSlingJoint->GetJointAngle ( ) >= CC_DEGREES_TO_RADIANS ( 10 ) ) m_bTargetThrough = KD_TRUE; m_pWorld->DestroyJoint ( m_pMouseJoint ); m_pMouseJoint = KD_NULL; } }
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:14,
示例18: b2Vec2void Flame::createBody(){ b2World* world = GameManager::getInstance()->getBox2dWorld(); b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody; bodyDef.position = b2Vec2(getParent()->convertToWorldSpace(getPosition()).x/PTM_RATIO,getParent()->convertToWorldSpace(getPosition()).y/PTM_RATIO); bodyDef.angle = -CC_DEGREES_TO_RADIANS(getRotation()); bodyDef.linearDamping = 0.3; bodyDef.userData = this; _body = world->CreateBody(&bodyDef); GB2ShapeCache* _fixturesCache = ((LayerItem*)getParent()->getUserObject())->_fixturesCache; switch (_type) { case Flame_Blue: _fixturesCache->addFixturesToBody(_body, "Flame_Blue"); break; case Flame_Orange: _fixturesCache->addFixturesToBody(_body, "Flame_Orange"); break; case Flame_Violet: _fixturesCache->addFixturesToBody(_body, "Flame_Violet"); break; case Flame_White: _fixturesCache->addFixturesToBody(_body, "Flame_White"); break; default: break; } for (b2Fixture* fixture = _body->GetFixtureList(); fixture; fixture = fixture->GetNext()) { b2Shape* shape = fixture->GetShape(); if (shape->GetType() == b2Shape::Type::e_circle) { b2CircleShape* circleShape = (b2CircleShape*)shape; circleShape->m_radius *= getScale(); }else{ b2PolygonShape* polygonShape = (b2PolygonShape*)shape; int count = polygonShape->GetVertexCount(); for (int i = 0; i<count; i++) { polygonShape->m_vertices[i] *= getScale(); } } } b2MassData bodymassData; _body->GetMassData(&bodymassData); bodymassData.mass *= getScale(); bodymassData.I *= getScale(); _body->SetMassData(&bodymassData);}
开发者ID:linger2334,项目名称:Grow,代码行数:49,
示例19: MAXvoid TestParticleSystem::addParticle(){ TestParticle* particle = TestParticle::create(); // Time to live particle->timeToLive = MAX(life + lifeVar * CCRANDOM_MINUS1_1(), 0.0); // Position Vec2 srcPos = Vec2(); particle->pos = Vec2(srcPos.x + posVar.x * CCRANDOM_MINUS1_1(), srcPos.y + posVar.y * CCRANDOM_MINUS1_1()); // Size particle->size = MAX(startSize + startSizeVar * CCRANDOM_MINUS1_1(), 0.0); float endSizeFinal = MAX(endSize + endSizeVar * CCRANDOM_MINUS1_1(), 0.0); particle->deltaSize = (endSizeFinal - particle->size) / particle->timeToLive; // Rotation particle->rotation = startRotation + startRotationVar * CCRANDOM_MINUS1_1(); float endRotationFinal = endRotation + endRotationVar * CCRANDOM_MINUS1_1(); particle->deltaRotation = (endRotationFinal - particle->rotation) / particle->timeToLive; // Direction float dirRadians = CC_DEGREES_TO_RADIANS(direction + directionVar * CCRANDOM_MINUS1_1()); Vec2 dirVector = Vec2(cosf(dirRadians), sin(dirRadians)); float speedFinal = speed + speedVar * CCRANDOM_MINUS1_1(); dirVector.scale(speedFinal); particle->dir = dirVector; // Accelerations particle->radialAccel = radialAcceleration + radialAccelerationVar * CCRANDOM_MINUS1_1(); particle->tangentialAccel = tangentialAcceleration + tangentialAccelerationVar; // Colors particle->simpleColorSequence[0] = 255.0; particle->simpleColorSequence[1] = 255.0; particle->simpleColorSequence[2] = 255.0; particle->simpleColorSequence[3] = 255.0; particle->simpleColorSequence[4] = 255.0; particle->simpleColorSequence[5] = 0.0; particle->simpleColorSequence[6] = 0.0; particle->simpleColorSequence[7] = 0.0; particle->transform = Mat4(); particles.pushBack(particle); numEmittedParticles++;}
开发者ID:vlidholt,项目名称:Test,代码行数:49,
示例20: setTargetvoid Missile::update(float dt){ if(!_target) { //setTarget(static_cast<GameLayer*>(getParent())->_testDummy);//very hacky setTarget(static_cast<GameEntity*>(EnemyController::enemies.getRandomObject())); } if(_target){ //turn towards the target float angle = -CC_RADIANS_TO_DEGREES((getPosition() - _target->getPosition()).getAngle()); if(fabsf(angle-90)>70) { //too much angle to track, get another target instead _target = nullptr; } float curRot = getRotation(); float angleDif = std::min(std::max((angle-90) - curRot, -_turnRate*dt), _turnRate*dt); float f = curRot + angleDif; setRotation(f); setPosition(getPosition()+Point(sinf(CC_DEGREES_TO_RADIANS(f))*_velocity,cosf(CC_DEGREES_TO_RADIANS(f))*_velocity) + _vector*dt); _vector = _vector * (1-dt); } else{ float f = getRotation(); setRotation(f); setPosition(getPosition()+Point(sinf(CC_DEGREES_TO_RADIANS(f))*_velocity,cosf(CC_DEGREES_TO_RADIANS(f))*_velocity) + _vector*dt); _vector = _vector * (1-dt*0.5); } // missiles need to rotate _yRotation += _yRotSpeed*dt; _Model->setRotation3D(Vertex3F(90,_yRotation, 0)); _velocity += _accel*dt;}
开发者ID:fanleesong,项目名称:EarthWarrior3D,代码行数:36,
示例21: unschedulevoid BigDude::shoot(float dt){ if(GameLayer::isDie) { unschedule(schedule_selector(BigDude::shoot)); return; } //Point bulletVec = Point(getRotation()) Point offset1 = getPosition(); Point offset2 = offset1; float angle = CC_DEGREES_TO_RADIANS(-getRotation()+90); float offsetRad = CC_DEGREES_TO_RADIANS(45); offset1.x += cosf(angle+offsetRad)*-50; offset1.y += sinf(angle+offsetRad)*-50; offset2.x += cosf(angle-offsetRad)*-50; offset2.y += sinf(angle-offsetRad)*-50; //this->showMuzzle(); auto bullet =BulletController::spawnBullet(kEnemyBullet, offset1, Point(cosf(angle)*-500, sinf(angle)*-500)); bullet->setRotation(-CC_RADIANS_TO_DEGREES(angle)-90); bullet =BulletController::spawnBullet(kEnemyBullet, offset2, Point(cosf(angle)*-500, sinf(angle)*-500)); bullet->setRotation(-CC_RADIANS_TO_DEGREES(angle)-90); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("boom.mp3");}
开发者ID:Creativegame,项目名称:Cocos2d-x-EarthWarrior3D-win-desktop-version,代码行数:24,
示例22: CC_DEGREES_TO_RADIANSvoid LotteryRotateView::_addRotateCell(int idx, const char* itemStr){ float rotateAngleArr[12] = {0, 30, 60, 90, 120, 150, 180, -150, -120, -90, -60, -30}; float rotateAngle = rotateAngleArr[idx]; CCSize size = m_pContainer->getContentSize(); // CCLOG("_addRotateCell_id:%s,angle:%f",itemStr,rotateAngle); LotteryActCell* cell = LotteryActCell::create(itemStr); float radians = CC_DEGREES_TO_RADIANS(rotateAngle); cell->setAngle(radians); cell->setTag(idx); m_pContainer->addChild(cell); }
开发者ID:ourgames,项目名称:dc208,代码行数:15,
示例23: CC_DEGREES_TO_RADIANS//////////////////////////////////////////////////// // Rotates object to give angle, if state is idile// than it is a simple translation, if rotating than// creates a rotate joint to rotate object along // it's axis//////////////////////////////////////////////////// void GameObject::rotate( float newRotation ){ if( ! getParent() ) { // not rotating if this object has no parent return ; } for( std::vector<b2Body*>::iterator bit = m_bodies.begin(); bit != m_bodies.end(); ++bit ) { b2Body *body = *bit; float32 b2Angle = -1 * CC_DEGREES_TO_RADIANS( newRotation ); body->SetTransform( body->GetPosition(), b2Angle ); }}
开发者ID:Freezzz,项目名称:Constructor,代码行数:21,
示例24: Color4Bvoid BillboardParticleSystem::updateQuadWithParticle(sBillboardParticle* particle, const Vec3& newPosition){ V3F_C4B_T2F_Quad *quad; quad = &(_quads[_particleIdx]); Color4B color = (_opacityModifyRGB) ? Color4B( particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255) : Color4B( particle->color.r*255, particle->color.g*255, particle->color.b*255, particle->color.a*255); quad->bl.colors = color; quad->br.colors = color; quad->tl.colors = color; quad->tr.colors = color; Vec3 billboardX = _cameraRight.getNormalized(); Vec3 billboardY = _cameraUp.getNormalized(); float fLeft = -0.5f; float fRight = 0.5f; float fTop = 0.5f; float fBottom = -0.5f; Vec3 leftOff = billboardX * particle->size * fLeft; Vec3 rightOff = billboardX * particle->size * fRight; Vec3 topOff = billboardY * particle->size * fTop; Vec3 bottomOff = billboardY * particle->size * fBottom; Vec3 vOffset[4]; vOffset[0] = leftOff + bottomOff; vOffset[1] = rightOff + bottomOff; vOffset[2] = leftOff + topOff; vOffset[3] = rightOff + topOff; if (particle->rotation) { Vec3 axis=vOffset[3] - vOffset[0]; axis.cross((vOffset[2] - vOffset[1])); Mat4 rotMat; Mat4::createRotation(axis, CC_DEGREES_TO_RADIANS(particle->rotation), &rotMat); rotMat.transformVector(&vOffset[0]); rotMat.transformVector(&vOffset[1]); rotMat.transformVector(&vOffset[2]); rotMat.transformVector(&vOffset[3]); } quad->bl.vertices = newPosition + vOffset[0]; // bottom-right vertex: quad->br.vertices = newPosition + vOffset[1]; // top-left vertex: quad->tl.vertices= newPosition + vOffset[2]; // top-right vertex: quad->tr.vertices = newPosition + vOffset[3]; }
开发者ID:tieunun,项目名称:FantasyWarrior3D,代码行数:48,
示例25: assertvoid Matrix::createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane, Matrix* dst){ assert(dst); float f_n = 1.0f / (zFarPlane - zNearPlane); float factor = 1.0f / tanf(CC_DEGREES_TO_RADIANS(fieldOfView) * 0.5f); memset(dst, 0, MATRIX_SIZE); dst->m[0] = (1.0f / aspectRatio) * factor; dst->m[5] = factor; dst->m[10] = (-(zFarPlane + zNearPlane)) * f_n; dst->m[11] = -1.0f; dst->m[14] = -2.0f * zFarPlane * zNearPlane * f_n;}
开发者ID:cn00,项目名称:MJ,代码行数:16,
示例26: cpBodySetAnglevoid PhysicsSprite::setRotation(float fRotation){ if (_ignoreBodyRotation) { Sprite::setRotation(fRotation); }#if CC_ENABLE_CHIPMUNK_INTEGRATION else { cpBodySetAngle(_CPBody, -CC_DEGREES_TO_RADIANS(fRotation)); }#elif CC_ENABLE_BOX2D_INTEGRATION else {
开发者ID:BeemoLin,项目名称:daca,代码行数:16,
示例27: originalVertexvoid LFTwirl::update(float time){ //// 优化部分 //{ // flag ++; // if (flag % 2 != 0) // return; // flag = 0; //} int i, j; int index = 0; for (i = 0; i < m_sGridSize.width + 1; ++i) { for (j = 0; j < m_sGridSize.height + 1; ++j) { ccVertex3F v = originalVertex(ccp(i, j)); CCPoint relativedPos = ccp(v.x - m_position.x,v.y - m_position.y); CCPoint newPos; float dis = 0.0f; if (gridDistanceArray) { dis = gridDistanceArray[index];index++; }else { dis = ccpLength(relativedPos) + 1.0f; } // 基于相对中心坐标计算 { float tempAngle = mAngle; tempAngle = tempAngle / dis * (mRadius*10);// 跟半径成反比,半径越大,转动角度越小 newPos = ccpRotateByAngle(relativedPos,ccp(1,0),CC_DEGREES_TO_RADIANS(tempAngle)); newPos.x *= mScale; newPos.y *= mScale; } v.x = newPos.x + m_position.x ; v.y = newPos.y + m_position.y; setVertex(ccp(i, j), v); } } mScale *= mScaleFactor; mAngle += mAngleFactor;}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:47,
示例28: CC_DEGREES_TO_RADIANSvoid Physics3DTestDemo::onTouchesMoved(const std::vector<Touch*>& touches, cocos2d::Event *event){ if (touches.size() && _camera) { auto touch = touches[0]; auto delta = touch->getDelta(); _angle -= CC_DEGREES_TO_RADIANS(delta.x); _camera->setPosition3D(Vec3(100.0f * sinf(_angle), 50.0f, 100.0f * cosf(_angle))); _camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)); if (delta.lengthSquared() > 16) { _needShootBox = false; } }}
开发者ID:dianz,项目名称:dianzcocostest,代码行数:17,
示例29: b2Vec2void PiecesLayer::onTouchMoved( Touch* touch, Event *event ){ auto location = touch->getLocation(); if(!m_bMouseDown){ return; } m_vec2_2->updatefunc(location.x ,location.y); m_nAngle = Vector2::Angle(*m_vec2_1 , *m_vec2_2);//degree m_vec2_1->updatefunc(location.x ,location.y); float p_rotation = paddleNode->getRotation(); paddleNode->setRotation(p_rotation + m_nAngle); //for (int i = 0;i<12;i++) //{ // if (paddles[i] && paddleBodies[i]) // { // Vec2 position = paddleNode->convertToWorldSpace(paddles[i]->getPosition()); // b2Vec2 p_position = b2Vec2(position.x / WORLDSCALE, position.y / WORLDSCALE); // float p_angle = -( CC_DEGREES_TO_RADIANS(paddleNode->getRotation() + 150 - 30 * i) ); // //b2Body *paddleBody = (b2Body *)paddles[i]->getUserData(); // paddleBodies[i]->SetTransform(p_position,p_angle); // } //} for (int i = 0;i<12;i++) { Sprite* m_paddle = Paddles[i]->m_paddle; Vec2 position = paddleNode->convertToWorldSpace(m_paddle->getPosition()); b2Vec2 p_position = b2Vec2(position.x / WORLDSCALE, position.y / WORLDSCALE); float p_angle = -( CC_DEGREES_TO_RADIANS(paddleNode->getRotation() + 150 - 30 * i) ); //b2Body *paddleBody = (b2Body *)paddles[i]->getUserData(); if (Paddles[i]->m_paddleBody) { Paddles[i]->m_paddleBody->SetTransform(p_position,p_angle); } } m_nAngle = 0.0;}
开发者ID:BL01,项目名称:breakout-legacy-00,代码行数:45,
示例30: cpvforangleCCAffineTransform cpCCNode::nodeToParentTransform ( KDvoid ){ cpBody* pBody = m_pImplementation->getBody ( ); cpVect tRot = m_pImplementation->isIgnoreRotation ( ) ? cpvforangle ( -CC_DEGREES_TO_RADIANS ( m_tRotation.x ) ) : pBody->rot; KDfloat x = pBody->p.x + tRot.x * -m_tAnchorPointInPoints.x - tRot.y * - m_tAnchorPointInPoints.y; KDfloat y = pBody->p.y + tRot.y * -m_tAnchorPointInPoints.x + tRot.x * - m_tAnchorPointInPoints.y; if ( m_pImplementation->isIgnoreRotation ( ) ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } m_tTransform = CCAffineTransformMake ( tRot.x, tRot.y, -tRot.y, tRot.x, x, y ); return m_tTransform;}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:18,
注:本文中的CC_DEGREES_TO_RADIANS函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES函数代码示例 C++ CC_CONTINUE_IF函数代码示例 |