예제 #1
0
const Vec2& GameData::getNearTargetByPos( const Vec2& curPos )
{
	Vec2 nearPos = Vec2(0,0);
	float dis = 100000.0f;
	auto plVec = m_EnemyPlaneVec;
	for (auto it = plVec.begin(); it != plVec.end(); it++)
	{
		auto pl = (*it);
		if (pl)
		{
			Vec2 pos = pl->convertToWorldSpaceAR(Vec2::ZERO);
			float TempDis = pos.distance(curPos);
			if (TempDis < dis)
			{
				dis = TempDis;
				nearPos = pos;
			}
		}
		else
		{
			log("");
		}
	}
	return nearPos;
}
예제 #2
0
void Weapon::onEnter()
{
	Node::onEnter();
	if (m_ConfigIsAmmi)
	{
		//朝向主飞机
		auto mainPl = GameData::getInstance()->getMainPlane();
		if (mainPl)
		{
			auto plPos = mainPl->convertToWorldSpaceAR(Vec2::ZERO);
			auto myPos = convertToWorldSpaceAR(Vec2::ZERO);

			auto vec = plPos - myPos;
			float angle = vec.getAngle() * RAD_DEG;
			setRotation(-angle);
		}
	}
}
예제 #3
0
void PlaneProtect::ClearScreen()
{
	auto mainpl = GameData::getInstance()->getMainPlane();
	if (mainpl)
	{
		auto pos = mainpl->convertToWorldSpaceAR(Vec2::ZERO);
		//破裂粒子效果
		auto layer = UIController::getInstance()->getEffectsLayer();
		EffectsManager::addParticle("particla/SpeedUpOver/SpeedUpOver.plist",layer,
			pos,true,1.0f);
	}
}
예제 #4
0
bool PowerUp::CheckPowerUpCol(Rect collBxCheck)
{
	Rect modifiedJumpBoostPowerUp;
	modifiedJumpBoostPowerUp.size = jumpBoostPowerUp->getBoundingBox().size;
	modifiedJumpBoostPowerUp.origin = convertToWorldSpaceAR(jumpBoostPowerUp->getBoundingBox().origin);

	if (modifiedJumpBoostPowerUp.intersectsRect(collBxCheck) && (GameManager::sharedGameManager()->GetJump() < 0))
	{
		return true;
	}

	return false;
}
예제 #5
0
const CCRect ClippingArea::convertStencilToWorldRect()
{
    //该函数应该在已经加入父节点的情况下才能使用
    if (!getParent())
    {
        CCLog("ClippingArea::convertToWorldRect不存在父节点");

        return CCRectMake(0, 0, 0, 0);
    }

    CCRect box = m_Stencil->boundingBox();

    //获取左下角坐标
    CCPoint posLB = ccp(box.origin.x, box.origin.y);
    //获取右上角坐标
    CCPoint posRT = ccpAdd(posLB, ccp(box.size.width, box.size.height));

    //转换为世界坐标
    CCPoint posLBW = convertToWorldSpaceAR(posLB);
    CCPoint posRTW = convertToWorldSpaceAR(posRT);
    
    return CCRectMake(posLBW.x, posLBW.y, posRTW.x - posLBW.x, posRTW.y - posLBW.y);
}
예제 #6
0
void ExplisonScreen::onEnter()
{
	PhysicsUnit::onEnter();

	//先爆圈,再全屏爆炸
	auto pl = GameData::getInstance()->getMainPlane();
	auto pos = pl->convertToWorldSpaceAR(Vec2::ZERO);

	NewAudio::getInstance()->playEff(Music_SpeedOver);

	auto layer = UIController::getInstance()->getEffectsLayer();
	EffectsManager::addParticle("particla/SpeedUpOver/SpeedUpOver.plist",layer,pos);

	ActionInterval* delay = DelayTime::create(0.5f);
	CallFunc* func = CallFunc::create(this,callfunc_selector(ExplisonScreen::StartExp));
	ActionInterval* seq = Sequence::create(delay, func, nullptr);
	runAction(seq);
}
예제 #7
0
void EditorWeapon::initFireAngle() {
    this->fireAngle = this->baseAngle;
    if(this->isAim) {
        Vec2 parentPos = this->getParent()->getParent()->getPosition();
        auto size = Director::getInstance()->getVisibleSize();
        Vec2 mainPos = Vec2(size.width * 0.5,0);
        auto mainPlane = GameData::getInstance()->getMainPlane();
        if(mainPlane)
        {
            mainPos = mainPlane->convertToWorldSpaceAR(Vec2::ZERO);
            auto v = mainPos - parentPos;
            float angle =  -(v.getAngle() * Pi2Angle) + 90;
            this->fireAngle = angle + (this->fireAngle - 180);
        }
    }

    if(this->info->followWeaponFlag()) {
        this->fireAngle = this->getParent()->getParent()->getRotation();
    } else {
        this->fireAngle += this->getParent()->getParent()->getRotation();
    }
}