Exemplo n.º 1
0
NS_MAIN_BEGIN

void Mainui::onLoadScene()
{
	setAutoRemoveUnusedTexture(true);
	TuiManager::getInstance()->parseScene(this,"panel_main",PATH_MAIN);

	//注册事件
	CControlView *ctlv = (CControlView*)this->getControl(PANEL_MAIN,CTLV_LEFT);
	ctlv->setOnControlListener(this,ccw_control_selector(Mainui::event_ctlv_left));

	CButton *pBtnOk = (CButton*)this->getControl(PANEL_MAIN,BTN_OK);
	pBtnOk->setOnClickListener(this,ccw_click_selector(Mainui::event_btn_ok));

	CButton *pBtnGo = (CButton*)this->getControl(PANEL_MAIN,BTN_GO);
	pBtnGo->setOnClickListener(this,ccw_click_selector(Mainui::event_btn_go));

	CButton *pShowPhone = (CButton*)this->getControl(PANEL_MAIN, BTN_SHOWPHONE);
	pShowPhone->setOnClickListener(this, ccw_click_selector(Mainui::event_btn_showphone));

	CToggleView *pTgvA = (CToggleView*)this->getControl(PANEL_MAIN, TGV_A);
	pTgvA->setOnCheckListener(this, ccw_check_selector(Mainui::event_tgvA_check));

	CToggleView *pTgvB = (CToggleView*)this->getControl(PANEL_MAIN, TGV_B);
	pTgvB->setOnCheckListener(this, ccw_check_selector(Mainui::event_tgvB_check));

	MovieView *pMovie = (MovieView*)this->getControl(PANEL_MAIN, MOVIE_TEST);
	map<string, function<void()>> m;
	m["finish"] = bind(&Mainui::event_movie_finish, this);
	pMovie->setCallBack(m);

	//播放骨骼动画(默认不播放)
	Armature *armature = (Armature*)this->getControl(PANEL_MAIN,ARMATURE_BOSS1);
	armature->getAnimation()->play("live",-1,1);
}
Exemplo n.º 2
0
CControlView* CControlView::create(const char* pBaseBoard, const char* pJoystick)
{
	CControlView* pRet = new CControlView();
	if( pRet && pRet->initWithFile(pBaseBoard, pJoystick) )
	{
		pRet->autorelease();
		return pRet;
	}
	CC_SAFE_DELETE(pRet);
	return NULL;
}
Exemplo n.º 3
0
CControlView* CControlView::create()
{
	CControlView* pRet = new CControlView();
	if( pRet && pRet->init() )
	{
		pRet->autorelease();
		return pRet;
	}
	CC_SAFE_DELETE(pRet);
	return NULL;
}
Exemplo n.º 4
0
bool CControlViewBasicTest::init()
{
	CControlViewTestSceneBase::init();
	setTitle("CControlViewBasicTest");
	setDescription("control the icon to move");

	m_pIcon = Sprite::create("icon.png");
	m_pIcon->setPosition(Vec2(480, 320));
	m_pWindow->addChild(m_pIcon);

	CControlView* pView = CControlView::create(
		"control_baseboard.png", "control_joystick.png");
	pView->setPosition(Vec2(100, 100));
	pView->setRadius(pView->getContentSize().width / 2);
	pView->setOnControlListener(this, ccw_control_selector(CControlViewBasicTest::onTouched));
	pView->setAnchorPoint(Vec2::ZERO);
	pView->setScale(1.5f);
	pView->setOpacity(200);
	m_pWindow->addChild(pView);

	CControlView* pView2 = CControlView::create();
	pView2->setBaseBoardImage("control_baseboard.png");
	pView2->setPosition(Vec2(860, 100));
	pView2->setRadius(pView2->getContentSize().width / 2);
	pView2->setOnControlListener(this, ccw_control_selector(CControlViewBasicTest::onTouched));
	pView2->setAnchorPoint(Vec2(1, 0));
	pView2->setScale(1.5f);
	pView2->setOpacity(200);
	m_pWindow->addChild(pView2);

	return true;
}
Exemplo n.º 5
0
CControlView* TuiManager::createControl(float tag,const char* baseboard,const char* joystick,float x,float y,float rotation){
	CControlView* pView = NULL;
	if(m_isUseSpriteFrame){
		pView = CControlView::create();
		pView->setBaseBoardSpriteFrameName(baseboard);
		pView->setJoystickSpriteFrameName(joystick);
	}else{
		pView = CControlView::create(baseboard,joystick);
	}
	pView->setPosition(Point(x, -y));
	pView->setRadius(pView->getContentSize().width / 2);
	pView->setRotation(rotation);
	pView->setTag(tag);
	return pView;
}