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;
			}
		}
	}

}