Exemple #1
0
void ChunkBase::activatePhysicsBody()
{
	if (!mPhysicsAttached) {
		if (mPhysicsBody == 0) initPhysicsBody();

		if (isEmpty) return;

		mLevel.getPhysicsWorld().addRigidBody(mPhysicsBody);
		mPhysicsAttached = true;
	}
}
Exemple #2
0
void ChunkBase::update(bool force)
{
	if (force) {
		mIsModified = true;
	}

	if (mIsModified) {
		initEntity();

		if (isEmpty) return;

		initPhysicsBody();
		activateEntity();
		activatePhysicsBody();
	}
}
Exemple #3
0
Enemy::Enemy(const std::string str) {
	_sprite = Sprite::create(str + "/idle_1.png");
	initPhysicsBody();
}
Exemple #4
0
Enemy::Enemy() : Actor() {
	initPhysicsBody();
}
Exemple #5
0
Enemy::Enemy(const std::string str, float x, float y) {
	_sprite = Sprite::create(str + "/idle_1.png");
	initPhysicsBody();
	setPosition(x, y);
}
Exemple #6
0
//vertical인 경우 바닥에, horizontal인 경우 왼쪽 벽에 붙여주시죠.
void LaserTrap::setLaser(bool isVertical, int interval)
{
	cocos2d::Rect bodyRect;
	if(isVertical)
	{
		cocos2d::Point curPos = getPosition();
		cocos2d::Size tileSize = GET_DATA_MANAGER()->getTileSize();
		cocos2d::Size moveUnit(0, tileSize.height);
		cocos2d::Point checkPos = curPos - moveUnit; //아래쪽 타일
		int stageNum = GET_STAGE_MANAGER()->getStageNum();
		int roomNum = GET_STAGE_MANAGER()->getRoomNum();
		int checkType = OT_START;

		//제대로 세팅했는지 검사
		checkType = GET_DATA_MANAGER()->getTileData(stageNum, roomNum, checkPos);
		if(checkType != OT_BLOCK)
		{
			cocos2d::log("laser set in wrong position.");
			return;
		}

		auto lower = GET_RESOURCE_MANAGER()->createSprite(ST_LASER_LOWER);
		auto upper = GET_RESOURCE_MANAGER()->createSprite(ST_LASER_UPPER);
		addChild(lower);
		addChild(upper);
		lower->setAnchorPoint(cocos2d::Point::ZERO);
		upper->setAnchorPoint(cocos2d::Point::ZERO);
		lower->setPosition(cocos2d::Point(0, 0));

		m_Laser = cocos2d::Sprite::create();
		addChild(m_Laser, -1);
		m_Laser->setAnchorPoint(cocos2d::Point::ZERO);

		checkType = OT_START;
		checkPos = curPos;
		int height = 0;
		while(true)
		{
			checkType = GET_DATA_MANAGER()->getTileData(stageNum, roomNum, checkPos);
			auto laser = GET_RESOURCE_MANAGER()->createSprite(ST_LASER_RELEASE);
			m_Laser->addChild(laser);
			laser->setPosition(cocos2d::Point(0, height));
			laser->setAnchorPoint(cocos2d::Point::ZERO);
			if(checkType == OT_BLOCK)
			{
				break;
			}
			height += tileSize.height;
			checkPos += moveUnit;
			if(height > MAX_HEIGHT)
			{
				this->release();
				return;
			}
		}

		if(checkType == OT_BLOCK)
		{
			upper->setPosition(cocos2d::Point(0, height - tileSize.height));
		}
		bodyRect = cocos2d::Rect(tileSize.width / 2, 0, LASER_WIDTH, height);
	}
	initPhysicsBody(bodyRect, PHYC_TRAP);
	m_Interval = interval - OT_LASER;
	switchTurn(m_IsOn);
}