void NestedTest::setup() { static int depth = 9; CCNode *parent = this; for (int i = 0; i < depth; i++) { int size = 225 - i * (225 / (depth * 2)); CCClippingNode *clipper = CCClippingNode::create(); clipper->setContentSize(CCSizeMake(size, size)); clipper->setAnchorPoint(ccp(0.5, 0.5)); clipper->setPosition( ccp(parent->getContentSize().width / 2, parent->getContentSize().height / 2) ); clipper->setAlphaThreshold(0.05f); clipper->runAction(CCRepeatForever::create(CCRotateBy::create(i % 3 ? 1.33 : 1.66, i % 2 ? 90 : -90))); parent->addChild(clipper); CCNode *stencil = CCSprite::create(s_pPathGrossini); stencil->setScale( 2.5 - (i * (2.5 / depth)) ); stencil->setAnchorPoint( ccp(0.5, 0.5) ); stencil->setPosition( ccp(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); stencil->setVisible(false); stencil->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(i), CCShow::create())); clipper->setStencil(stencil); clipper->addChild(stencil); parent = clipper; } }
void ScrollViewDemo::setup() { CCClippingNode *clipper = CCClippingNode::create(); clipper->setTag( kTagClipperNode ); clipper->setContentSize( CCSizeMake(200, 200) ); clipper->setAnchorPoint( ccp(0.5, 0.5) ); clipper->setPosition( ccp(this->getContentSize().width / 2, this->getContentSize().height / 2) ); clipper->runAction(CCRepeatForever::create(CCRotateBy::create(1, 45))); this->addChild(clipper); CCDrawNode *stencil = CCDrawNode::create(); CCPoint rectangle[4]; rectangle[0] = ccp(0, 0); rectangle[1] = ccp(clipper->getContentSize().width, 0); rectangle[2] = ccp(clipper->getContentSize().width, clipper->getContentSize().height); rectangle[3] = ccp(0, clipper->getContentSize().height); ccColor4F white = {1, 1, 1, 1}; stencil->drawPolygon(rectangle, 4, white, 1, white); clipper->setStencil(stencil); CCSprite *content = CCSprite::create(s_back2); content->setTag( kTagContentNode ); content->setAnchorPoint( ccp(0.5, 0.5) ); content->setPosition( ccp(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); clipper->addChild(content); m_bScrolling = false; this->setTouchEnabled(true); }
bool Recipe26::init() { if ( !RecipeBase::init() ) { return false; } CCLayerColor* panelBg = CCLayerColor::create(ccc4(51, 51, 51, 255),640,1150); panelBg->setPosition(ccp(0,0)); this->addChild(panelBg); targetLayer = CCLayer::create(); this->addChild(targetLayer); // 画面の幅を取得 CCSize winSize = CCDirector::sharedDirector()->getWinSize(); // 画像ファイルとrectを指定してスプライトを作成 CCSprite *player = CCSprite::create("image/quest/shuriken_m_avatar_skillpg_18.png", CCRectMake(0, 0, 100, 100) ); // スプライトの位置を設定 player->setPosition(ccp(player->getContentSize().width*3/2, winSize.height/2)); // 後で識別できるようにタグを設定 player->setTag(1); // スプライトをレイヤに追加 targetLayer->addChild(player); CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); TapSprite* sprite = (TapSprite*)TapSprite::create("image/quest/shuriken_m_avatar_skillpg_18.png"); sprite->setPosition(ccp(visibleSize.width/2, visibleSize.height/2)); sprite->setTag(2); targetLayer->addChild(sprite); // クリック用のボタン CCMenuItemImage *pCloseItem = CCMenuItemImage::create( "image/ui/common_ui_mainButton_up.png", "image/ui/common_ui_mainButton_down.png", this, menu_selector(Recipe26::testBtn1Handler)); // 表示位置を指定 pCloseItem->setPosition(ccp(winSize.width - pCloseItem->getContentSize().width / 2 , pCloseItem->getContentSize().height / 2)); // CCMenuItemImage から CCMenuを作成 CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); // CCMenuとしての位置は(0,0)を指定 pMenu->setPosition(-150,130); this->addChild(pMenu); //--------------------------- CCSize size = CCDirector::sharedDirector()->getVisibleSize(); CCSprite* pSprite = CCSprite::create("image/gacha/2204401.jpg"); pSprite->setPosition( ccp(size.width/2, size.height/2) ); CCSprite* pMask = CCSprite::create("image/quest/mask_star.png"); pMask->setPosition(ccp(size.width/2, size.height/2)); CCClippingNode* pClip = CCClippingNode::create(); pClip->setStencil(pMask); pClip->setAlphaThreshold(0.05f); pClip->addChild(pSprite); targetLayer->addChild(pClip); CCMoveTo *actionMove = CCMoveTo::create(1.7f, ccp(200, 500)); pClip->runAction(CCEaseExponentialInOut::create(actionMove)); //--------------------------- // 配列のテスト //--------------------------- int arrN[] = {5,6,9,4}; int iSize = sizeof(arrN) / sizeof(arrN[0]); for ( int i = 0 ; i < iSize ; i++ ) { CCLOG("ffgff : %i" , arrN[i]); } return true; }