cocos2dx使用cocostudio UI Editor

把 UI Editor 中的导出文件 Export 放入cocos2dx 中的 Resources中


然后再代码中添加代码


 
 
 
 
void WelcomeLayer::startartGameCallback(Object* sender ,  TouchEventType type)
{
	switch (type)
	{
	case TOUCH_EVENT_BEGAN:
		log("began");
		break;
	case TOUCH_EVENT_MOVED:
		log("moved");
		break;
	case TOUCH_EVENT_ENDED:
		log("end");
		break;
	case TOUCH_EVENT_CANCELED:
		log("canceled");
		break;
	default:
		break;
	}
}
void WelcomeLayer::initSkin()
{
	UILayer* uiLayer = UILayer::create();
	addChild(uiLayer);
	//通过UIHelper的单例进行解析Json文件, 把创建的UI层加载近来
	Layout* uiLayout = (Layout*)UIHelper::instance()->createWidgetFromJsonFile("UIStartGame/UIStartGame.json");
	uiLayer->addWidget(uiLayout);

	btnStartGame =(UIButton*) uiLayer->getWidgetByName("btnStartGame");
	btnStartGame->addTouchEventListener(this, SEL_TouchEvent(&WelcomeLayer::startartGameCallback));

}




你可能感兴趣的:(cocos2dx使用cocostudio UI Editor)