예제 #1
0
void GameScene::moveToXY(int moveID, int killID, int tox, int toy){
	// 判断是否可以移动到xy位置,如果是并移动到xy的位置,并将select_id 置为-1
	if (killID != -1 && sts[moveID]->getisRed() == sts[killID]->getisRed()){
		setSelectedID(killID);
		return;
	}
	// 判断是否可以移动棋子
	bool canMove = isCanMove(moveID, killID, tox, toy);
	if (!canMove){
		return;
	}
	// 记录走的每一步
	Step* itemsStep = Step::create(moveID, killID, sts[moveID]->getX(), sts[moveID]->getY(), tox, toy);
	steps->addObject(itemsStep);

	sts[moveID]->setX(tox);
	sts[moveID]->setY(toy);
	sts[moveID]->setZOrder(sts[moveID]->getZOrder() + 1);
	MoveTo* moveTo = MoveTo::create(0.5f, Vec2(sts[moveID]->getRealX(), sts[moveID]->getRealY()));
	CallFuncN* actionCallback = CallFuncN::create(CC_CALLBACK_1(GameScene::onActionComplete, this, moveID, killID));
	Sequence* seq = Sequence::create(moveTo, actionCallback, NULL);
	sts[moveID]->runAction(seq);

	spriteSelected->setVisible(false);
	select_id = -1;
	isRedTurn = !isRedTurn;
}
예제 #2
0
파일: glass.cpp 프로젝트: rgde/rgdengine
	void Glass::checkBricks()
	{
		for (uint i = 0; i < m_field.size(); ++i)
		{
			Line& l = m_field[i];
			for(uint j = 0; j < l.size(); ++j)
			{
				Brick& b = l[j]; 
				if (-1 != b.id)
				{
					b.falling = !b.falling && isCanMove(b, Down);					
				}
			}
		}
	}
예제 #3
0
void GameScene::fakeMove(Step* step){
	int moveID = step->moveID;
	int killID = step->killID;
	int moveToX = step->moveToX;
	int moveToY = step->moveToY;
	if (isCanMove(moveID, killID, moveToX, moveToY)){
		Stone* moveStone = sts[moveID];
		moveStone->setX(moveToX);
		moveStone->setY(moveToY);
		if (killID != -1){
			Stone* killStone = sts[killID];
			killStone->setisDead(true);
		}
		this->isRedTurn = !this->isRedTurn;
	}
}