示例#1
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;
}
示例#2
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);
}