예제 #1
0
void Slider::initRenderer()
{
    _barRenderer = CCSprite::create();
    _progressBarRenderer = CCSprite::create();
    _progressBarRenderer->setAnchorPoint(CCPoint(0.0f, 0.5f));
    CCNodeRGBA::addChild(_barRenderer, BASEBAR_RENDERER_Z, -1);
    CCNodeRGBA::addChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1);
    _slidBallNormalRenderer = CCSprite::create();
    _slidBallPressedRenderer = CCSprite::create();
    _slidBallPressedRenderer->setVisible(false);
    _slidBallDisabledRenderer = CCSprite::create();
    _slidBallDisabledRenderer->setVisible(false);
    _slidBallRenderer = CCNode::create();
    _slidBallRenderer->addChild(_slidBallNormalRenderer);
    _slidBallRenderer->addChild(_slidBallPressedRenderer);
    _slidBallRenderer->addChild(_slidBallDisabledRenderer);
    CCNodeRGBA::addChild(_slidBallRenderer, SLIDBALL_RENDERER_Z, -1);
}
예제 #2
0
bool CButtonEventTest::init()
{
	CButtonTestSceneBase::init();
	setTitle("CButtonEventTest");
	setDescription("button events");

	CButton* pButton1 = CButton::create("btn1_1.png", "btn1_2.png", "btn1_3.png");
	pButton1->setOnTouchBeganListener(this, ccw_touchbegan_selector(CButtonEventTest::onTouchBegan));
	pButton1->setOnTouchMovedListener(this, ccw_touchevent_selector(CButtonEventTest::onTouchMoved));
	pButton1->setOnTouchEndedListener(this, ccw_touchevent_selector(CButtonEventTest::onTouchEnded));
	pButton1->setOnTouchCancelledListener(this, ccw_touchevent_selector(CButtonEventTest::onTouchCancelled));
	pButton1->setPosition(CCPoint(350, 320));
	m_pWindow->addChild(pButton1);

	m_pText1 = CLabel::create();
	m_pText1->setAnchorPoint(CCPoint(0, 0.5));
	m_pText1->setPosition(CCPoint(260, 430));
	m_pText1->setFontSize(35.0f);
	m_pText1->setString("none");
	m_pWindow->addChild(m_pText1);

	m_pDurationText = CLabel::create();
	m_pDurationText->setPosition(CCPoint(260, 390));
	m_pDurationText->setFontSize(35.0f);
	m_pDurationText->setString("ms:0");
	m_pDurationText->setAnchorPoint(CCPoint(0, 0.5));
	m_pWindow->addChild(m_pDurationText);

	CButton* pButton2 = CButton::create("btn1_1.png", "btn1_2.png", "btn1_3.png");
	pButton2->setOnClickListener(this, ccw_click_selector(CButtonEventTest::onClick));
	pButton2->setPosition(CCPoint(610, 320));
	m_pWindow->addChild(pButton2);

	m_pText2 = CLabel::create();
	m_pText2->setAnchorPoint(CCPoint(0, 0.5));
	m_pText2->setPosition(CCPoint(520, 430));
	m_pText2->setFontSize(35.0f);
	m_pText2->setString("none");
	m_pWindow->addChild(m_pText2);

	return true;
}
예제 #3
0
CAImage* CAProgress::getImage(CAImage* image)
{
    CCRect rect;
    rect.origin = ccpSub(ccpMult(image->getContentSize(), 0.5f), CCPoint(0.5f, 0.5f));
    rect.size = CCSize(1, 1);
    
	CAScale9ImageView *scale9Image = CAScale9ImageView::createWithImage(rect, image);
    scale9Image->setAnchorPoint(CCPointZero);
	scale9Image->setPreferredSize(this->getBounds().size);
    this->addSubview(scale9Image);
    
	CCRenderTexture* render = CCRenderTexture::create(this->getBounds().size.width, this->getBounds().size.height, kCAImagePixelFormat_RGBA8888);
	render->beginWithClear(0, 0, 0, 0);
    scale9Image->visit();
	render->end();
    scale9Image->removeFromSuperview();
	return render->getSprite()->getImage();
}
예제 #4
0
void CCheckBox::setNormalSpriteFrame(CCSpriteFrame* pFrame)
{
	if( pFrame )
	{
		if( m_pNormal )
		{
			m_pNormal->setDisplayFrame(pFrame);
			setContentSize(m_pNormal->getContentSize());
		}
		else
		{
			m_pNormal = CCSprite::createWithSpriteFrame(pFrame);
			setContentSize(m_pNormal->getContentSize());
			addChild(m_pNormal);
		}
		m_pNormal->setPosition(CCPoint(m_obContentSize.width/2, m_obContentSize.height/2));
	}
}
예제 #5
0
파일: UIWidget.cpp 프로젝트: fordream/quick
bool Widget::init()
{
    if (CCNode::init())
    {
        _widgetChildren = CCArray::create();
        CC_SAFE_RETAIN(_widgetChildren);
        _layoutParameterDictionary = CCDictionary::create();
        CC_SAFE_RETAIN(_layoutParameterDictionary);
        _nodes = CCArray::create();
        CC_SAFE_RETAIN(_nodes);
        initRenderer();
        setBright(true);
        ignoreContentAdaptWithSize(true);
        setAnchorPoint(CCPoint(0.5f, 0.5f));
        return true;
    }
    return false;
}
예제 #6
0
void CCheckBox::setNormalPressTexture(CCTexture2D* pTexture)
{
	if( m_pNormalPress )
	{
		m_pNormalPress->setTexture(pTexture);

		CCRect tRect = CCRectZero;
		tRect.size = pTexture->getContentSize();
		m_pNormalPress->setTextureRect(tRect);
	}
	else
	{
		m_pNormalPress = CCSprite::createWithTexture(pTexture);
		addChild(m_pNormalPress);
	}
	m_pNormalPress->setVisible(false);
	m_pNormalPress->setPosition(CCPoint(m_obContentSize.width/2, m_obContentSize.height/2));
}
예제 #7
0
void CANavigationController::pushViewController(CAViewController* viewController, bool animated)
{
    if (this->getView()->getSuperview() == NULL)
    {
        return;
    }

    if (m_pContainer->getActionByTag(0))
    {
        return;
    }

    float x = m_pContainer->getFrame().size.width;
    
    CAViewController* lastViewController = m_pViewControllers.back();
    lastViewController->getView()->setFrame(CCRect(-x, 0, 0, 0));
    viewController->retain();
    viewController->m_pNavigationController = this;
    m_pViewControllers.push_back(viewController);
    if (viewController->getNavigationBarItem() == NULL && viewController->getTitle().compare("") != 0)
    {
        viewController->setNavigationBarItem(CANavigationBarItem::create(viewController->getTitle()));
    }
    m_pNavigationBar->pushItem(viewController->getNavigationBarItem());
    viewController->addViewFromSuperview(m_pContainer);
    
    if (animated)
    {
        m_pContainer->stopAllActions();
        m_pContainer->setFrame(CCRect(x, m_pContainer->getFrame().origin.y, 0, 0));
        
        CCDelayTime* delayTime = CCDelayTime::create(0.1f);
        CCMoveBy* moveBy = CCMoveBy::create(0.3f, CCPoint(-x, 0));
        CCEaseSineOut* easeBack = CCEaseSineOut::create(moveBy);
        CCCallFunc* finish = CCCallFunc::create(this, callfunc_selector(CANavigationController::pushViewControllerFinish));
        CCSequence* actions = CCSequence::create(delayTime, easeBack, finish, NULL);
        m_pContainer->runAction(actions);
        actions->setTag(0);
    }
    else
    {
        this->pushViewControllerFinish();
    }
}
예제 #8
0
CAImage* CAProgress::getImage(CAImage* image)
{
	CCScale9Sprite *scale9Image = CCScale9Sprite::createWithImage(image);
    CCRect rect;
    rect.origin = scale9Image->getFrame().size/2;
    rect.origin = ccpSub(rect.origin, CCPoint(0.5f, 0.5f));
    rect.size = CCSize(1, 1);
    scale9Image->setCapInsets(rect);
	scale9Image->setPreferredSize(this->getBounds().size);
    scale9Image->setAnchorPoint(CCPointZero);
    this->addSubview(scale9Image);
    
	CCRenderTexture* render = CCRenderTexture::create(this->getBounds().size.width, this->getBounds().size.height, kCCTexture2DPixelFormat_RGBA8888);
	render->beginWithClear(0, 0, 0, 0);
    scale9Image->visit();
	render->end();
    scale9Image->removeFromSuperview();
	return render->getSprite()->getImage();
}
예제 #9
0
void MyScene::addBackground(){
	CCTMXTiledMap* pTmap = CCTMXTiledMap::create("TileMaps/TestDesert.tmx");
	pTmap->setName("Tmap");
	backgroundNode = CCParallaxNode::create();
	backgroundNode->setName("Background");
	backgroundNode->addChild(pTmap, 1, ccp(1.0f, 1.0f), ccp(0, 0));
	this->addChild(backgroundNode, 0);

	CCTMXObjectGroup* objects = pTmap->objectGroupNamed("Objects");
	ValueMap& spawnPoint = objects->getObject("SpawnPoint");
	CCTMXLayer* metaInfo = pTmap->getLayer("MetaInfo");
	metaInfo->setVisible(false);

	//create a dragon on "SpawnPoint"
	int x = spawnPoint["x"].asInt();
	int y = spawnPoint["y"].asInt();

	this->createDragon(CCPoint(ccp(x, y)));
}
void CNetworkPlayerNumberLayer::CreateBackButtonMenu( CCSize visibleSize )
{
	CCMenu *BackButtonTable = CCMenu::createWithItems(NULL, NULL);
    
	CCMenuItemImage* pBackButton = CCMenuItemImage::create(
                                                           SHARED_BTN_BACK.c_str(),
                                                           SHARED_BTN_BACK.c_str(),
                                                           this,
                                                           menu_selector(CNetworkPlayerNumberLayer::MainSceneCallback)
                                                           );
    
	pBackButton->setAnchorPoint( ccp(0, 0) );
	pBackButton->setPosition( CCPoint( WAITING_CHANNEL_BACK_BUTTON_POSITION ) );
    
	BackButtonTable->addChild(pBackButton);
	BackButtonTable->setPosition( ccp(0, 0) );
    
	this->addChild(BackButtonTable);
}
예제 #11
0
void CATextSelViewEx::showTextSelView(CAView* pControlView, const std::vector<CCRect>& vt, float iLineHeight)
{
    setFrame(this->getSuperview()->getFrame());
	setColor(CAColor_clear);
	showTextViewMark(vt);

	CCRect r = (vt.size() == 1) ? vt[0] : vt.back();

	CCPoint pt1 = vt[0].origin;
	CCPoint pt2 = CCPoint(r.origin.x + r.size.width, r.origin.y + r.size.height);

	m_pCursorMarkL->setFrame(CCRect(pt1.x - CATextSelectArrWidth, pt1.y + iLineHeight, CATextSelectArrWidth, CATextSelectArrHeight));
	m_pCursorMarkL->setVisible(true);

	m_pCursorMarkR->setFrame(CCRect(pt2.x, pt2.y, CATextSelectArrWidth, CATextSelectArrHeight));
	m_pCursorMarkR->setVisible(true);
    this->setVisible(true);
	m_pControlView = pControlView;
}
예제 #12
0
파일: CABar.cpp 프로젝트: Jimlan/CrossApp
void CATabBar::setSelectedAtIndex(int index)
{
    do
    {
        CC_BREAK_IF(index < 0);
        CC_BREAK_IF(index >= m_pItems.size());

        if (m_pSelectedItem && m_pSelectedItem->getSelectedImage())
        {
            CAView* viewLast = m_pViews.at(m_nSelectedIndex);
            if (CAImageView* imageView = dynamic_cast<CAImageView*>(viewLast->getSubviewByTag(0xffff)))
            {
                imageView->setImage(m_pSelectedItem->getImage());
            }
        }
        
        m_nSelectedIndex = index;
        m_pSelectedItem = m_pItems.at(m_nSelectedIndex);
        m_pSelectedBackGround->setFrame(m_pViews.at(m_nSelectedIndex)->getFrame());
        
        if (m_pSelectedIndicator)
        {
            ((CCScale9Sprite*)m_pSelectedIndicator)->setPreferredSize(CCSize(m_cItemSize.width, m_cItemSize.height / 10));
            m_pSelectedIndicator->stopAllActions();
            CCPoint p = CCPoint(m_pSelectedBackGround->getFrame().origin.x, m_pSelectedBackGround->getFrame().size.height);
            CCMoveTo* moveTo = CCMoveTo::create(0.3f, p);
            CCEaseSineOut* easeBack = CCEaseSineOut::create(moveTo);
            m_pSelectedIndicator->runAction(easeBack);
        }
        
        if (m_pSelectedItem->getSelectedImage())
        {
            CAView* view = m_pViews.at(m_nSelectedIndex);
            if (CAImageView* imageView = dynamic_cast<CAImageView*>(view->getSubviewByTag(0xffff)))
            {
                imageView->setImage(m_pSelectedItem->getSelectedImage());
            }
        }
        
        m_pDelegate->tabBarSelectedItem(this, m_pSelectedItem, m_nSelectedIndex);
    }
    while (0);
}
void CNetworkPlayerNumberLayer::CreateNextButtonMenu( CCSize visibleSize )
{
	CCMenu *NextButtonTable = CCMenu::createWithItems(NULL, NULL);

	CCMenuItemImage* pNextButton = CCMenuItemImage::create(
		SHARED_BTN_NEXT.c_str(),
		SHARED_BTN_NEXT.c_str(),
		this,
		menu_selector(CNetworkPlayerNumberLayer::NextButtonCallBack)
		);

	pNextButton->setAnchorPoint( ccp(0, 0) );
	pNextButton->setPosition( CCPoint( PLAYER_NUMBER_NEXT_IMG_POS ) );

	NextButtonTable->addChild(pNextButton);
	NextButtonTable->setPosition( ccp(0, 0) );

	this->addChild(NextButtonTable);
}
예제 #14
0
파일: CABar.cpp 프로젝트: Jimlan/CrossApp
void CATabBar::showSelectedIndicator()
{
    if (m_pSelectedIndicator)
    {
        m_pSelectedIndicator->removeFromSuperview();
        m_pSelectedIndicator=NULL;
    }
    
    if (m_pSelectedIndicatorImage == NULL)
    {
        m_pSelectedIndicatorImage = CAImage::create("tabBarController_selected_bottom.png");
    }
    
    m_pSelectedIndicator = CCScale9Sprite::createWithImage(m_pSelectedIndicatorImage);
    ((CCScale9Sprite*)m_pSelectedIndicator)->setPreferredSize(CCSize(m_cItemSize.width, m_cItemSize.height / 10));
    m_pSelectedIndicator->setAnchorPoint(CCPoint(0.0f, 1.0f));
    m_pSelectedIndicator->setFrame(CCRect(0, this->getBounds().size.height, 0, 0));
    this->insertSubview(m_pSelectedIndicator, 2);
}
예제 #15
0
bool CATextField::attachWithIME()
{
    bool bRet = CAIMEDelegate::attachWithIME();
    if (bRet)
    {
        // open keyboard
        CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView();
        if (pGlView)
        {
#if(CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM==CC_PLATFORM_IOS)
            if (getKeyboardType() ==KEY_BOARD_TYPE_NORMAL)
            {
                pGlView->setIMEKeyboardDefault();
            }
            else if (getKeyboardType() ==KEY_BOARD_TYPE_NUMBER)
            {
                pGlView->setIMEKeyboardNumber();
            }
            else if(getKeyboardType() ==KEY_BOARD_TYPE_ALPHABET)
            {
                pGlView->setIMEKeyboardAlphabet();
            }
            
            if (getKeyboardReturnType() ==KEY_BOARD_RETURN_SEND)
            {
                pGlView->setIMEKeyboardReturnSend();
            }
            else if (getKeyboardReturnType() ==KEY_BOARD_RETURN_SEARCH)
            {
                pGlView->setIMEKeyboardReturnSearch();
            }
            else if(getKeyboardReturnType() ==KEY_BOARD_RETURN_DONE)
            {
                pGlView->setIMEKeyboardReturnDone();
            }
#endif
            this->showCursorMark();
            m_pCursorMark->setCenterOrigin(CCPoint(getCursorX() + m_iHoriMargins, m_obContentSize.height / 2));
            pGlView->setIMEKeyboardState(true);
        }
    }
    return bRet;
}
예제 #16
0
void GameLayer::extraInit() {
    
    initRole();
    initGround();
    initCollisions();
    
    setRoleState(ROLE_STATE_JUMP_DOWN);
    setTouchEnabled(false);
    
    BBButton *button = BBButton::create(CCSizeMake(200, 60), this, bbButtonFunI_selector(GameLayer::restart), NULL, NULL, NULL, NULL, "Play Again");
    button->mLabel->setFontSize(30);
    button->setPosition(CCPoint(getContentSize().width - button->getContentSize().width, getContentSize().height - button->getContentSize().height));
    button->mDependedTarget = this;
    this->addChild(button, 10);
    
    setScore(0);
    
    beginCountdown(3);
}
예제 #17
0
void GestureRecognizer::initTemplates() {
	/** For test only */
	CCPoint rectPoints[] = {CCPoint(286.336243, 497.743988), CCPoint(286.336243, 489.771454), CCPoint(286.336243, 483.825806), CCPoint(286.336243, 467.813141), CCPoint(286.336243, 457.813660), CCPoint(286.336243, 445.854828), CCPoint(286.336243, 425.855896), CCPoint(286.336243, 413.897064), CCPoint(288.363159, 387.952484), CCPoint(292.416992, 359.980988), CCPoint(296.335724, 332.009491), CCPoint(296.335724, 320.050659), CCPoint(296.335724, 308.091858), CCPoint(296.335724, 302.078644), CCPoint(296.335724, 292.079163), CCPoint(296.335724, 286.133545), CCPoint(296.335724, 274.107147), CCPoint(296.335724, 268.161530), CCPoint(296.335724, 262.148315), CCPoint(296.335724, 260.121399), CCPoint(296.335724, 258.162048), CCPoint(296.335724, 256.135132), CCPoint(296.335724, 254.175766), CCPoint(296.335724, 252.148849), CCPoint(302.416473, 252.148849), CCPoint(306.335175, 252.148849), CCPoint(322.415405, 256.135132), CCPoint(364.305084, 256.135132), CCPoint(380.250183, 254.175766), CCPoint(420.248077, 246.135651), CCPoint(436.193176, 236.203751), CCPoint(470.110321, 228.163635), CCPoint(486.190552, 228.163635), CCPoint(492.136169, 228.163635), CCPoint(498.081818, 228.163635), CCPoint(504.162567, 228.163635), CCPoint(510.108215, 228.163635), CCPoint(516.053833, 228.163635), CCPoint(522.134583, 228.163635), CCPoint(528.080261, 228.163635), CCPoint(534.025879, 228.163635), CCPoint(544.025330, 228.163635), CCPoint(556.051758, 228.163635), CCPoint(561.997375, 228.163635), CCPoint(569.969910, 228.163635), CCPoint(571.996826, 228.163635), CCPoint(577.942444, 228.163635), CCPoint(584.023254, 228.163635), CCPoint(585.915039, 228.163635), CCPoint(587.941956, 228.163635), CCPoint(587.941956, 234.176834), CCPoint(587.941956, 240.190018), CCPoint(587.941956, 246.135651), CCPoint(587.941956, 256.135132), CCPoint(587.941956, 268.161530), CCPoint(587.941956, 274.107147), CCPoint(587.941956, 284.106628), CCPoint(587.941956, 294.106110), CCPoint(587.941956, 310.051208), CCPoint(587.941956, 322.077606), CCPoint(587.941956, 332.009491), CCPoint(587.941956, 342.008972), CCPoint(591.995789, 353.967804), CCPoint(593.887573, 371.939819), CCPoint(597.941406, 403.897614), CCPoint(597.941406, 419.910278), CCPoint(597.941406, 431.869080), CCPoint(597.941406, 437.882294), CCPoint(597.941406, 443.827911), CCPoint(597.941406, 449.841125), CCPoint(597.941406, 455.854309), CCPoint(597.941406, 461.799957), CCPoint(597.941406, 467.813141), CCPoint(597.941406, 473.826324), CCPoint(597.941406, 479.771973), CCPoint(597.941406, 485.785156), CCPoint(597.941406, 491.798370), CCPoint(597.941406, 493.757721), CCPoint(597.941406, 499.770905), CCPoint(597.941406, 501.797821), CCPoint(597.941406, 507.743469), CCPoint(597.941406, 509.770386), CCPoint(597.941406, 511.729736), CCPoint(597.941406, 513.756653), CCPoint(597.941406, 519.702271), CCPoint(597.941406, 525.715515), CCPoint(597.941406, 527.742432), CCPoint(595.914490, 527.742432), CCPoint(583.888123, 521.729187), CCPoint(577.942444, 517.742920), CCPoint(549.970947, 509.770386), CCPoint(486.055420, 501.797821), CCPoint(452.138306, 501.797821), CCPoint(442.138824, 501.797821), CCPoint(432.139343, 501.797821), CCPoint(426.193726, 501.797821), CCPoint(416.194244, 501.797821), CCPoint(410.113495, 501.797821), CCPoint(388.222748, 501.797821), CCPoint(372.277649, 501.797821), CCPoint(362.278168, 501.797821), CCPoint(350.251770, 501.797821), CCPoint(344.306152, 501.797821), CCPoint(338.225403, 501.797821), CCPoint(336.333588, 501.797821), CCPoint(330.252838, 501.797821), CCPoint(324.307190, 501.797821), CCPoint(318.361572, 499.770905), CCPoint(310.253906, 499.770905), CCPoint(308.362091, 499.770905), CCPoint(308.362091, 499.770905)};
	CCPoint circlePoints[] = {CCPoint(406.194763, 174.247559), CCPoint(404.302979, 174.247559), CCPoint(402.276062, 174.247559), CCPoint(400.249146, 174.247559), CCPoint(398.222229, 174.247559), CCPoint(396.330444, 174.247559), CCPoint(394.303497, 174.247559), CCPoint(392.276581, 174.247559), CCPoint(390.249664, 174.247559), CCPoint(388.222748, 174.247559), CCPoint(384.304047, 174.247559), CCPoint(382.277130, 174.247559), CCPoint(378.223267, 174.247559), CCPoint(372.277649, 174.247559), CCPoint(364.305084, 174.247559), CCPoint(358.359467, 174.247559), CCPoint(352.278687, 174.247559), CCPoint(352.278687, 176.274475), CCPoint(346.333069, 176.274475), CCPoint(340.387451, 176.274475), CCPoint(338.360504, 178.301392), CCPoint(332.414886, 180.260757), CCPoint(330.387970, 180.260757), CCPoint(326.334137, 182.287674), CCPoint(320.388489, 186.273956), CCPoint(318.361572, 188.233307), CCPoint(316.334656, 188.233307), CCPoint(310.389008, 192.219589), CCPoint(308.362091, 194.246506), CCPoint(302.416473, 200.259705), CCPoint(292.416992, 210.191605), CCPoint(290.390076, 212.218521), CCPoint(290.390076, 214.245453), CCPoint(286.471375, 220.191086), CCPoint(284.444458, 222.218002), CCPoint(280.390594, 228.163635), CCPoint(274.444977, 242.149384), CCPoint(272.418060, 250.189499), CCPoint(270.391144, 252.148849), CCPoint(268.364227, 252.148849), CCPoint(268.364227, 254.175766), CCPoint(266.472412, 256.135132), CCPoint(266.472412, 258.162048), CCPoint(264.445496, 262.148315), CCPoint(264.445496, 268.161530), CCPoint(264.445496, 272.147797), CCPoint(262.418579, 276.134064), CCPoint(262.418579, 284.106628), CCPoint(262.418579, 290.119812), CCPoint(262.418579, 296.065460), CCPoint(258.364746, 302.078644), CCPoint(258.364746, 308.091858), CCPoint(258.364746, 314.037476), CCPoint(258.364746, 320.050659), CCPoint(258.364746, 326.063873), CCPoint(258.364746, 332.009491), CCPoint(258.364746, 342.008972), CCPoint(258.364746, 348.022156), CCPoint(258.364746, 353.967804), CCPoint(258.364746, 359.980988), CCPoint(258.364746, 369.980469), CCPoint(258.364746, 379.979950), CCPoint(258.364746, 391.938782), CCPoint(258.364746, 397.951965), CCPoint(258.364746, 407.883881), CCPoint(258.364746, 417.883331), CCPoint(258.364746, 423.896545), CCPoint(258.364746, 433.896027), CCPoint(258.364746, 435.855377), CCPoint(258.364746, 439.841644), CCPoint(258.364746, 441.868561), CCPoint(258.364746, 447.881775), CCPoint(260.391663, 447.881775), CCPoint(260.391663, 453.827393), CCPoint(260.391663, 459.840576), CCPoint(262.418579, 465.853790), CCPoint(264.445496, 467.813141), CCPoint(268.364227, 473.826324), CCPoint(268.364227, 475.785706), CCPoint(270.391144, 479.771973), CCPoint(272.418060, 481.798889), CCPoint(282.282410, 489.771454), CCPoint(288.363159, 497.743988), CCPoint(292.281860, 503.757202), CCPoint(298.362640, 513.756653), CCPoint(304.308258, 515.716003), CCPoint(306.335175, 517.742920), CCPoint(308.362091, 517.742920), CCPoint(314.307739, 519.702271), CCPoint(322.280273, 523.756165), CCPoint(326.334137, 525.715515), CCPoint(340.252319, 531.728699), CCPoint(344.306152, 531.728699), CCPoint(346.197937, 533.688049), CCPoint(348.224854, 533.688049), CCPoint(350.251770, 533.688049), CCPoint(350.251770, 535.714966), CCPoint(356.197418, 535.714966), CCPoint(362.278168, 537.674316), CCPoint(374.169434, 537.674316), CCPoint(380.250183, 537.674316), CCPoint(386.195831, 537.674316), CCPoint(392.141449, 537.674316), CCPoint(398.222229, 537.674316), CCPoint(408.221680, 537.674316), CCPoint(418.086029, 537.674316), CCPoint(434.166260, 537.674316), CCPoint(450.111389, 537.674316), CCPoint(462.137756, 537.674316), CCPoint(478.082886, 541.728149), CCPoint(488.082336, 541.728149), CCPoint(499.973602, 539.701233), CCPoint(502.000519, 539.701233), CCPoint(504.027435, 539.701233), CCPoint(504.027435, 537.674316), CCPoint(509.973083, 535.714966), CCPoint(516.053833, 531.728699), CCPoint(534.025879, 523.756165), CCPoint(539.971497, 521.729187), CCPoint(557.943542, 509.770386), CCPoint(569.969910, 495.784637), CCPoint(575.915527, 489.771454), CCPoint(579.969360, 481.798889), CCPoint(587.941956, 469.840057), CCPoint(591.860657, 461.799957), CCPoint(597.941406, 455.854309), CCPoint(601.860107, 449.841125), CCPoint(601.860107, 447.881775), CCPoint(605.913940, 441.868561), CCPoint(605.913940, 439.841644), CCPoint(605.913940, 437.882294), CCPoint(605.913940, 433.896027), CCPoint(605.913940, 431.869080), CCPoint(605.913940, 429.909729), CCPoint(605.913940, 423.896545), CCPoint(605.913940, 421.869629), CCPoint(605.913940, 417.883331), CCPoint(605.913940, 411.937714), CCPoint(605.913940, 409.910797), CCPoint(605.913940, 405.924530), CCPoint(605.913940, 399.911316), CCPoint(605.913940, 391.938782), CCPoint(605.913940, 385.925568), CCPoint(603.887024, 385.925568), CCPoint(603.887024, 379.979950), CCPoint(599.968323, 373.966736), CCPoint(599.968323, 371.939819), CCPoint(599.968323, 367.953552), CCPoint(599.968323, 362.007904), CCPoint(593.887573, 353.967804), CCPoint(593.887573, 348.022156), CCPoint(589.968872, 342.008972), CCPoint(585.915039, 330.050140), CCPoint(585.915039, 324.036957), CCPoint(584.023254, 318.023743), CCPoint(579.969360, 306.064911), CCPoint(575.915527, 298.092377), CCPoint(574.023743, 296.065460), CCPoint(569.969910, 290.119812), CCPoint(564.024292, 288.092896), CCPoint(564.024292, 282.079712), CCPoint(557.943542, 278.093414), CCPoint(554.024780, 272.147797), CCPoint(539.971497, 264.107666), CCPoint(536.052795, 258.162048), CCPoint(534.025879, 258.162048), CCPoint(528.080261, 254.175766), CCPoint(526.053284, 254.175766), CCPoint(522.134583, 250.189499), CCPoint(514.026917, 248.162582), CCPoint(514.026917, 246.135651), CCPoint(512.135132, 246.135651), CCPoint(512.135132, 244.176300), CCPoint(506.054382, 242.149384), CCPoint(504.027435, 242.149384), CCPoint(500.108734, 242.149384), CCPoint(498.081818, 240.190018), CCPoint(496.054901, 238.163101), CCPoint(490.109253, 234.176834), CCPoint(488.082336, 234.176834), CCPoint(486.055420, 234.176834), CCPoint(480.109802, 234.176834), CCPoint(478.082886, 232.217468), CCPoint(476.191071, 232.217468), CCPoint(474.164154, 230.190552), CCPoint(468.083405, 230.190552), CCPoint(466.191620, 230.190552), CCPoint(460.110840, 230.190552), CCPoint(460.110840, 228.163635), CCPoint(458.219055, 228.163635), CCPoint(456.192139, 228.163635), CCPoint(456.192139, 226.204269), CCPoint(454.165222, 226.204269), CCPoint(452.138306, 226.204269), CCPoint(452.138306, 224.177353), CCPoint(450.111389, 224.177353), CCPoint(450.111389, 222.218002), CCPoint(448.219574, 222.218002), CCPoint(446.192657, 222.218002), CCPoint(444.165741, 220.191086), CCPoint(442.138824, 220.191086), CCPoint(442.138824, 218.231720), CCPoint(440.247040, 218.231720), CCPoint(438.220123, 218.231720), CCPoint(436.193176, 218.231720), CCPoint(436.193176, 218.231720)};
	CCPoint triPoints[] = {CCPoint(450.111389, 505.784119), CCPoint(448.084442, 503.757202), CCPoint(442.138824, 495.784637), CCPoint(428.085510, 485.785156), CCPoint(408.221680, 459.840576), CCPoint(392.141449, 445.854828), CCPoint(386.195831, 441.868561), CCPoint(376.196350, 427.882813), CCPoint(368.223816, 421.869629), CCPoint(362.278168, 413.897064), CCPoint(360.251251, 413.897064), CCPoint(350.251770, 407.883881), CCPoint(336.333588, 391.938782), CCPoint(324.307190, 373.966736), CCPoint(312.280823, 365.994202), CCPoint(292.416992, 345.995239), CCPoint(268.364227, 326.063873), CCPoint(256.472961, 314.037476), CCPoint(226.474533, 296.065460), CCPoint(212.556351, 282.079712), CCPoint(198.503036, 272.147797), CCPoint(190.530487, 264.107666), CCPoint(178.504089, 250.189499), CCPoint(162.558990, 232.217468), CCPoint(152.559509, 222.218002), CCPoint(144.586960, 214.245453), CCPoint(142.560043, 214.245453), CCPoint(142.560043, 212.218521), CCPoint(146.613876, 212.218521), CCPoint(156.613358, 212.218521), CCPoint(162.558990, 208.232254), CCPoint(184.584854, 208.232254), CCPoint(196.476120, 208.232254), CCPoint(206.475586, 204.245972), CCPoint(256.472961, 196.273422), CCPoint(278.363678, 192.219589), CCPoint(326.334137, 188.233307), CCPoint(374.304565, 184.247025), CCPoint(402.276062, 184.247025), CCPoint(412.275543, 184.247025), CCPoint(428.220642, 184.247025), CCPoint(434.166260, 184.247025), CCPoint(440.247040, 184.247025), CCPoint(446.192657, 184.247025), CCPoint(448.219574, 184.247025), CCPoint(450.246490, 184.247025), CCPoint(454.165222, 184.247025), CCPoint(462.137756, 184.247025), CCPoint(472.137238, 184.247025), CCPoint(488.082336, 188.233307), CCPoint(504.162567, 188.233307), CCPoint(530.107178, 188.233307), CCPoint(541.998413, 188.233307), CCPoint(551.997864, 188.233307), CCPoint(564.024292, 188.233307), CCPoint(579.969360, 188.233307), CCPoint(581.996277, 188.233307), CCPoint(584.023254, 188.233307), CCPoint(589.968872, 188.233307), CCPoint(595.914490, 188.233307), CCPoint(601.995239, 188.233307), CCPoint(615.913452, 188.233307), CCPoint(625.912903, 188.233307), CCPoint(637.939270, 188.233307), CCPoint(643.884949, 188.233307), CCPoint(649.965698, 188.233307), CCPoint(651.857483, 188.233307), CCPoint(655.911316, 188.233307), CCPoint(657.938232, 188.233307), CCPoint(659.830017, 188.233307), CCPoint(667.937744, 188.233307), CCPoint(673.883362, 188.233307), CCPoint(675.910278, 188.233307), CCPoint(681.855896, 188.233307), CCPoint(687.801514, 188.233307), CCPoint(689.828430, 188.233307), CCPoint(689.828430, 190.260223), CCPoint(689.828430, 192.219589), CCPoint(689.828430, 196.273422), CCPoint(687.801514, 196.273422), CCPoint(687.801514, 198.232773), CCPoint(685.909729, 204.245972), CCPoint(683.882813, 206.205338), CCPoint(681.855896, 206.205338), CCPoint(679.828979, 208.232254), CCPoint(679.828979, 210.191605), CCPoint(679.828979, 212.218521), CCPoint(677.802063, 212.218521), CCPoint(677.802063, 214.245453), CCPoint(677.802063, 218.231720), CCPoint(675.910278, 220.191086), CCPoint(669.829529, 226.204269), CCPoint(663.883850, 240.190018), CCPoint(643.884949, 254.175766), CCPoint(635.912354, 266.134613), CCPoint(609.967773, 302.078644), CCPoint(585.915039, 322.077606), CCPoint(571.996826, 334.036407), CCPoint(564.024292, 345.995239), CCPoint(554.024780, 365.994202), CCPoint(538.079712, 379.979950), CCPoint(529.972046, 391.938782), CCPoint(524.026367, 409.910797), CCPoint(518.080750, 421.869629), CCPoint(510.108215, 429.909729), CCPoint(506.054382, 441.868561), CCPoint(490.109253, 461.799957), CCPoint(486.055420, 467.813141), CCPoint(486.055420, 473.826324), CCPoint(486.055420, 475.785706), CCPoint(484.028503, 477.812622), CCPoint(484.028503, 479.771973), CCPoint(484.028503, 481.798889), CCPoint(482.001587, 483.825806), CCPoint(482.001587, 489.771454), CCPoint(482.001587, 491.798370), CCPoint(480.109802, 491.798370), CCPoint(480.109802, 493.757721), CCPoint(478.082886, 499.770905), CCPoint(476.055939, 501.797821), CCPoint(474.029022, 503.757202), CCPoint(474.029022, 505.784119), CCPoint(472.137238, 505.784119), CCPoint(470.110321, 505.784119), CCPoint(470.110321, 505.784119)};
	
	vector<CCPoint> rectSamples (rectPoints, rectPoints + sizeof(rectPoints) / sizeof(CCPoint));
	vector<CCPoint> circleSamples (circlePoints, circlePoints + sizeof(circlePoints) / sizeof(CCPoint));
	vector<CCPoint> triSamples (triPoints, triPoints + sizeof(triPoints) / sizeof(CCPoint));

	generateIntoTemplate("Rectangle", rectSamples);
	generateIntoTemplate("Circle", circleSamples);
	generateIntoTemplate("Triangle", triSamples);
}
예제 #18
0
void CATextField::ccTouchEnded(CATouch *pTouch, CAEvent *pEvent)
{
	CATouchView::ccTouchEnded(pTouch, pEvent);

	if (CATextToolBarView::isTextToolBarShow())
		return;

    if (m_bMoved)
    {
        m_bMoved = false;
        return;
    }
    
    CCPoint point = this->convertTouchToNodeSpace(pTouch);
    
    if (this->getBounds().containsPoint(point))
    {
        if (canAttachWithIME())
        {
            becomeFirstResponder();
            
            calculateSelChars(point, m_iString_l_length, m_iString_r_length, m_iCurPos);
            
            m_pCursorMark->setCenterOrigin(CCPoint(getCursorX() + m_iHoriMargins, m_obContentSize.height / 2));
            
#if CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID
            CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView();
            pGlView->setIMECursorPos(getCursorPos(), getContentText());
#endif
        }
    }
    else
    {
        if (canDetachWithIME())
        {
            resignFirstResponder();
        }
    }

	m_curSelCharRange = std::make_pair(m_iCurPos, m_iCurPos);
	execCurSelCharRange();
}
예제 #19
0
//设置背景
void WellcomeScene:: AddBackGround()
{
    CCSize size= winsize;
    
    CCSprite *backgound=CCSprite::create("heiye.png");
    backgound->setPosition(CCPoint(size.width*0.5f, size.height*0.5f));
    backgound->setScaleX(size.width/backgound->getContentSize().width +0.1f);
    backgound->setScaleY(size.height/backgound->getContentSize().height +0.1f);
    this->addChild(backgound, 0, 0);
    CCSprite *logo=CCSprite::create("logo.png");
    logo->setPosition(ccp(_bird->getPosition().x, _bird->getPosition().y+140.0f));
    logo->setScale(1.4f);
    this->addChild(logo,0);
    
    CCLabelTTF *copyright=CCLabelTTF::create("(c) jsonmess 2014.7","FlappyBird/Abduction.ttf", 22.0f);
    copyright->setPosition(ccp(size.width*0.5f, size.height/8));
    
    copyright->setFontFillColor(ccWHITE);
    this->addChild(copyright,1);
}
예제 #20
0
bool CATextField::becomeFirstResponder()
{
	resignAllResponder(this);
    
	bool result = CAView::becomeFirstResponder();
    if (result) 
	{
		result = attachWithIME();
        this->showCursorMark();

        calculateSelChars(CCPoint(this->getCursorX() + m_iHoriMargins, m_obContentSize.height / 2), m_iString_l_length, m_iString_r_length, m_iCurPos);
        setCursorPosition();

#if CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID
        CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView();
        pGlView->setIMECursorPos(getCursorPos(), getContentText());
#endif
    }
    return result;
}
예제 #21
0
void CATextField::setText(const std::string &var)
{
    CATextFieldDelegate* pTemp = m_pDelegate;
    m_pDelegate = NULL;
    m_sText.clear();
	m_iCurPos = 0;
	m_curSelCharRange = std::make_pair(0, 0);
	m_iString_o_length = 0;
	m_iString_l_length = 0;
	m_iString_r_length = 0;
	m_vTextFiledChars.clear();
    CCPoint p = CCPoint(this->getCursorX() + m_iHoriMargins, m_obContentSize.height / 2);
    m_pCursorMark->setCenterOrigin(p);
    insertText(var.c_str(), (int)var.length());
    m_pDelegate = pTemp;
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
	CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView();
	pGlView->setIMECursorPos(getCursorPos(), getContentText());
#endif
}
void CCClippingRegionNode::visit()
{
    if (m_clippingEnabled)
    {
        glEnable(GL_SCISSOR_TEST);

        const CCPoint pos = convertToWorldSpace(CCPoint(m_clippingRegion.origin.x, m_clippingRegion.origin.y));
        CCDirector::sharedDirector()->getOpenGLView()->setScissorInPoints(pos.x * m_fScaleX,
                pos.y * m_fScaleX,
                m_clippingRegion.size.width * m_fScaleY,
                m_clippingRegion.size.height * m_fScaleY);
    }

    CCNode::visit();

    if (m_clippingEnabled)
    {
        glDisable(GL_SCISSOR_TEST);
    }
}
bool UIScrollViewTest_Horizontal_Editor::init()
{
    if (UIScene_Editor::init())
    {
        _layout = static_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile("cocosgui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/ui_scrollview_horizontal_editor_1.json"));
        _touchGroup->addWidget(_layout);
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        CCSize rootSize = _layout->getSize();
        _touchGroup->setPosition(CCPoint((screenSize.width - rootSize.width) / 2,
                                        (screenSize.height - rootSize.height) / 2));
        
        Layout* root = static_cast<Layout*>(_touchGroup->getWidgetByName("root_Panel"));
        
        ui::Label* back_label = static_cast<ui::Label*>(UIHelper::seekWidgetByName(root, "back"));
        back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
        
        _sceneTitle = static_cast<ui::Label*>(UIHelper::seekWidgetByName(root, "UItest"));
        
        Button* left_button = Button::create();
        left_button->loadTextures("images/b1.png", "images/b2.png", "");
        left_button->setPosition(ccp(_layout->getSize().width / 2 - left_button->getSize().width,
                                     left_button->getSize().height * 0.625));
        left_button->setTouchEnabled(true);
        left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
        left_button->setZOrder(_layout->getZOrder() + 1);
        _layout->addChild(left_button);
        
        Button* right_button = Button::create();
        right_button->loadTextures("images/f1.png", "images/f2.png", "");
        right_button->setPosition(ccp(_layout->getSize().width / 2 + right_button->getSize().width,
                                      right_button->getSize().height * 0.625));
        right_button->setTouchEnabled(true);
        right_button->setZOrder(_layout->getZOrder() + 1);
        right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
        _layout->addChild(right_button);
        
        return true;
    }
    
    return false;
}
예제 #24
0
CAViewController* CANavigationController::popViewControllerAnimated(bool animated)
{
    if (m_pViewControllers.size() == 1)
    {
        return NULL;
    }

    if (m_pContainer->getActionByTag(0))
    {
        return NULL;
    }
    
    unsigned int index = m_pViewControllers.size() - 2;
    CAViewController* showViewController = m_pViewControllers.at(index);
    showViewController->getView()->setFrame(CCRectZero);
    m_pContainer->addSubview(showViewController->getView());
    
    CAViewController* backViewController = m_pViewControllers.back();
    
    float x = m_pContainer->getFrame().size.width;
    backViewController->getView()->setFrame(CCRect(x, 0, 0, 0));
    
    if (animated)
    {
        m_pContainer->stopAllActions();
        m_pContainer->setFrame(CCRect(-x, m_pContainer->getFrame().origin.y, 0, 0));
        
        CCDelayTime* delayTime = CCDelayTime::create(0.1f);
        CCMoveBy* moveBy = CCMoveBy::create(0.3f, CCPoint(x, 0));
        CCEaseSineOut* easeBack = CCEaseSineOut::create(moveBy);
        CCCallFunc* finish = CCCallFunc::create(this, callfunc_selector(CANavigationController::popViewControllerFinish));
        CCSequence* actions = CCSequence::create(delayTime, easeBack, finish, NULL);
        m_pContainer->runAction(actions);
        actions->setTag(0);
    }
    else
    {
        this->popViewControllerFinish();
    }
    return backViewController;
}
예제 #25
0
void MenuScene::onLoadScene()
{
	m_vMenuItems.push_back("Basic Test");

	CCSize tContainerSize = CCSize(700, 100 * m_vMenuItems.size());

	CCLayer* pScrollViewContainer = CCLayer::create();
	pScrollViewContainer->setPosition(CCPointZero);
	pScrollViewContainer->setContentSize(tContainerSize);

	m_pScrollView = CCScrollView::create(CCSize(700, 640));
	m_pScrollView->setDirection(kCCScrollViewDirectionVertical);
	m_pScrollView->ignoreAnchorPointForPosition(false);
	m_pScrollView->setPosition(CCPoint(480, 320));
	m_pScrollView->setContainer(pScrollViewContainer);
	addChild(m_pScrollView);

	CCArray* pArray = CCArray::create();
	
	float height = tContainerSize.height;

	unsigned int i = 0;
	unsigned int end = m_vMenuItems.size();
	for(; i < end; ++i )
	{
		CCMenuItemFont* pFont = CCMenuItemFont::create(m_vMenuItems[i].c_str());
		pFont->setTarget(this, menu_selector(MenuScene::onClick));
		pFont->setFontSizeObj(45.0f);
		pFont->setPosition(ccp(700 / 2, height - 100 / 2));
		pFont->setTag(i + 1);
		pArray->addObject(pFont);

		height -= 100;
	}

	CCMenu* pMenu = CCMenu::createWithArray(pArray);
	pMenu->setPosition(ccp(0,0));
	pScrollViewContainer->addChild(pMenu);

	m_pScrollView->setContentOffset(ccp(0, -(tContainerSize.height - 640)));
}
예제 #26
0
bool CCheckBoxExclusionTest::init()
{
	CCheckBoxTestSceneBase::init();
	setTitle("CCheckBoxExclusionTest");
	setDescription("checkbox exclusion test");

	CREATE_CHECKBOX(pCheckBox1, CCPoint(480, 490));
	pCheckBox1->setTag(1);
	pCheckBox1->setExclusion(1);
	pCheckBox1->setChecked(true);
	pCheckBox1->setEnabled(false);
	m_pWindow->addChild(pCheckBox1);

	CREATE_CHECKBOX(pCheckBox2, CCPoint(480, 425));
	pCheckBox2->setExclusion(1);
	m_pWindow->addChild(pCheckBox2);
	
	CREATE_CHECKBOX(pCheckBox3, CCPoint(480, 360));
	pCheckBox3->setExclusion(1);
	m_pWindow->addChild(pCheckBox3);

	CREATE_CHECKBOX(pCheckBox4, CCPoint(480, 295));
	pCheckBox4->setExclusion(1);
	m_pWindow->addChild(pCheckBox4);

	CREATE_CHECKBOX(pCheckBox5, CCPoint(480, 230));
	pCheckBox5->setExclusion(1);
	m_pWindow->addChild(pCheckBox5);

	CREATE_CHECKBOX(pCheckBox6, CCPoint(480, 165));
	pCheckBox6->setExclusion(1);
	m_pWindow->addChild(pCheckBox6);

	CButton* pButton = CButton::createWith9Sprite(CCSize(280, 60),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton->setPosition(CCPoint(200, 450));
	pButton->setUserTag(1);
	pButton->setOnClickListener(this, ccw_click_selector(CCheckBoxExclusionTest::onClick));
	pButton->initText("set true for first", "", 30);
	m_pWindow->addChild(pButton);

	return true;
}
예제 #27
0
   void DaFeiJi::movingBackground (float dt)
   {
        _backSky->runAction(CCMoveBy::create(3, CCPoint(0, -48)));
        _backTileMap->runAction(CCMoveBy::create(3, CCPoint(0, -200)));
        _backSkyHeight -= 48;
        _backTileMapHeight -= 200;

        if (_backSkyHeight <= _winSize.height) {
            if (!_isBackSkyReload) {
				_backSkyRe = CCSprite::create(s_bg01);
				_backSkyRe->setAnchorPoint(CCPoint(0, 0));
                addChild(_backSkyRe, -10);
                _backSkyRe->setPosition(CCPoint(0, _winSize.height));
                _isBackSkyReload = true;
            }
            _backSkyRe->runAction(CCMoveBy::create(3, CCPoint(0, -48)));
        }
        if (_backSkyHeight <= 0) {
            _backSkyHeight = _backSky->getContentSize().height;
            removeChild(_backSky, true);
            _backSky = _backSkyRe;
            _backSkyRe = NULL;
            _isBackSkyReload = false;
        }

        if (_backTileMapHeight <= _winSize.height) {
            if (!_isBackTileReload) {
				_backTileMapRe = CCTMXTiledMap::create(s_level01);
                addChild(_backTileMapRe, -9);
                _backTileMapRe->setPosition(CCPoint(0, _winSize.height));
                _isBackTileReload = true;
            }
            _backTileMapRe->runAction(CCMoveBy::create(3, CCPoint(0, -200)));
        }

        if (_backTileMapHeight <= 0) {
            _backTileMapHeight = _backTileMapRe->getMapSize().height * _backTileMapRe->getTileSize().height;
            removeChild(_backTileMap, true);
            _backTileMap = _backTileMapRe;
            _backTileMapRe = NULL;
            _isBackTileReload = false;
        }
    }
예제 #28
0
CCPoint calculateCosASinAOfVec1ToVec2(const CCPoint&vec1,const CCPoint&vec2)
//return {cos(vec1,vec2),sin(vec1,vec2)}
{
    float cosA=ccpDot(vec1, vec2)/(ccpLength(vec1)*ccpLength(vec2));
    float signalOfSinA;
    {
        float _vec1[3]={vec1.x,vec1.y,0};
        float _vec2[3]={vec2.x,vec2.y,0};
        float _rs[3];
        __cross(_vec1, _vec2, _rs);
        if (_rs[2]==0) {
            signalOfSinA=0;
        }else if(_rs[2]>0){
            signalOfSinA=1;
        }else{
            signalOfSinA=-1;
        }
    }
    float sinA=signalOfSinA*sqrtf(MAX(0,1-cosA*cosA));
    return CCPoint(cosA,sinA);
}
예제 #29
0
bool CAIndicator::initWithFrame(const CCRect& rect, CAIndicatorType type)
{
    if (!CAView::init())
    {
        return false;
    }
    this->setFrame(rect);
    
    m_eType = type;
    
    CAImage* image = CAImage::create("indicator.png");
    
    CCRect r;
    r.origin = ccpSub(ccpMult(image->getContentSize(), 0.5f), CCPoint(0.5f, 0.5f));
    r.size = CCSize(1.0f, 1.0f);
    
    m_pIndicator = CCScale9Sprite::createWithImage(r, image);
    this->addSubview(m_pIndicator);
    
    return true;
}
예제 #30
0
float StarPuzzle::puzzleStartAnimation() {
	float delayTime = 0.0f;
	float delayFactor = 0.08f;
	float baseActionTime = 0.8f;
	float actionTime = 0.0f;
	CCFiniteTimeAction *delay, *action, *seq;
	for (int i = 0; i < m_size; i++) {
		if (m_stars[i] != 0) {
			int r = row(i);
			int c = column(i);
			m_stars[i]->setPosition(m_left + c * STAR_WIDTH, m_top);
			delayTime = r * delayFactor * 2 + delayFactor * (i % 2);
			delay = CCDelayTime::create(delayTime);
			actionTime = (1 - r * STAR_HEIGHT / (m_top - m_bottom)) * baseActionTime;
			action = CCMoveTo::create(actionTime, CCPoint(m_left + c * STAR_WIDTH, m_bottom + r * STAR_HEIGHT));
			seq = CCSequence::create(delay, action, NULL);
			m_stars[i]->runAction(seq);
		}
	}
	return delayTime+0.2f;
}