Example #1
0
void T27ActionMore::ccTouchEnded(CCTouch* t, CCEvent*)
{
	CCPoint ptStart = t->getStartLocation();
	CCPoint ptEnd = t->getLocation();
	if (ptStart.getDistanceSq(ptEnd) <= 25)
	{
		// click
		// 点中了哪个子窗口
		
		// 转换ptStart为ScrollView中的Container的坐标
		// 再判断被点击的LayerColor
		CCPoint ptInContainer = _c->convertToNodeSpace(ptStart);
		CCArray* arr = _c->getChildren(); // 所有的layercolor
		for (int i = 0; i < sizeof(_actionName) / sizeof(*_actionName); i++)
		{
			CCLayerColor* layer = (CCLayerColor*)arr->objectAtIndex(i);
			if (layer->boundingBox().containsPoint(ptInContainer))
			{
				testAction(i, layer);
				break;
			}
		}
	}

}
Example #2
0
bool Common::Screen2Plate(const CCPoint& ptSceen, int& row, int& col)
{
	// 遍历所有象棋坐标点,计算棋盘格子中心坐标点到点击的店的距离,如果小于半径,那么就对了
	int distance = Stone::_d*Stone::_d / 4;
	for (row = 0; row <= 9; ++row)
	for (col = 0; col <= 8; ++col)
	{
		CCPoint ptCenter = Plate2Screen(row, col);
		if (ptCenter.getDistanceSq(ptSceen) < distance)
		{
			return true;
		}
	}
	return false;
}
Example #3
0
bool GameStartLayer::Screen2Plate(const CCPoint& ptScreen, int& row, int& col)
{
	//! 计算格子半径的平方
	int distance = Stone::_d*Stone::_d / 4;
	//! 遍历所有象棋坐标点, 判断是否有点在半径内
	for (row = 0; row <= 9; ++row)
	{
		for (col = 0; col <= 8;++col)
		{
			CCPoint ptCenter = Plate2Screen(row, col);
			//计算当前点击的点和棋子中心点的距离
			if (ptCenter.getDistanceSq(ptScreen) < distance)
			{
				return true;
			}
		}
	}
	return false;
}
Example #4
0
bool LayerMenu::isClick(CCTouch *pTouch)
{
	CCPoint ptStartLocation = pTouch->getStartLocation();
	CCPoint ptLocation = pTouch->getLocation();
	return ptLocation.getDistanceSq(ptStartLocation) < 25;
}