HelloWorld::HelloWorld() { setTouchEnabled( true ); setAccelerometerEnabled( true ); CCSize s = CCDirector::sharedDirector()->getWinSize(); // init physics this->initPhysics(); CCSpriteBatchNode *parent = CCSpriteBatchNode::create("blocks.png", 100); m_pSpriteTexture = parent->getTexture(); addChild(parent, 0, kTagParentNode); addNewSpriteAtPosition(ccp(s.width/2, s.height/2)); CCLabelTTF *label = CCLabelTTF::create("Tap screen", "Marker Felt", 32); addChild(label, 0); label->setColor(ccc3(0,0,255)); label->setPosition(ccp( s.width/2, s.height-50)); scheduleUpdate(); //set Icon in center TapSprite* icon = (TapSprite*)TapSprite::create("Icon-72.png"); icon->setPosition(ccp(s.width/2,s.height/2)); addChild(icon); }
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; }