Пример #1
0
void Tutorial::msg2(float time)
{

	Node* pMsg = Sprite::create("help_msg2.png");
	pMsg->setPosition(Point(280, visibleSize.height * 0.80-150));
	pMsg->setTag(tagMsg);
	this->addChild(pMsg,2);

	Node* pYubi  = this->getChildByTag(tagYubi);
	pYubi->runAction(RotateBy::create(0.5f, -90.0f));

	pMsg = Sprite::create("help_msg3.png");
	pMsg->setPosition(Point(visibleSize.width/2 , origin.y + 200));
	pMsg->setTag(tagTap2);
	this->addChild(pMsg,2);

	LabelTTF* arrowLabel = LabelTTF::create("タップしてね", "Arial", 40);
	arrowLabel->setColor(ccc3(0, 0, 0));
	arrowLabel->setPosition(Point(visibleSize.width/2 , origin.y + 200));
	arrowLabel->setTag(tagTap);
	this->addChild(arrowLabel,3);
	arrowLabel->runAction(CCRepeatForever::create(Blink::create(5,7)));

	scene_flag++;

}
Пример #2
0
TableViewCell* TableViewTestLayer::tableCellAtIndex(TableView *table, unsigned int idx)
{
    String *string = String::createWithFormat("%d", idx);
    TableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CustomTableViewCell();
        cell->autorelease();
        Sprite *sprite = Sprite::create("Images/Icon.png");
        sprite->setAnchorPoint(Point::ZERO);
        sprite->setPosition(Point(0, 0));
        cell->addChild(sprite);

        LabelTTF *label = LabelTTF::create(string->getCString(), "Helvetica", 20.0);
        label->setPosition(Point::ZERO);
		label->setAnchorPoint(Point::ZERO);
        label->setTag(123);
        cell->addChild(label);
    }
    else
    {
        LabelTTF *label = (LabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }


    return cell;
}
Пример #3
0
ControlButton* standardButtonWithTitle( const char * bgname, const char * bgseledname, const char * title){

	//Creates and return a button with a default background and title color.
//    Scale9Sprite *backgroundButton = Scale9Sprite::create(bgname);//按下前
//    Scale9Sprite *backgroundHighlightedButton = Scale9Sprite::create(bgseledname);//按下后
	

	ControlButton* btn = ControlButton::create();
	btn->setPreferredSize(Size(522, 88));

	Scale9Sprite*	normal = Scale9Sprite::create(bgname);
	Scale9Sprite*	select = Scale9Sprite::create(bgseledname);
	Scale9Sprite* hightlight = Scale9Sprite::create(bgseledname);
	Scale9Sprite* disable = Scale9Sprite::create(bgname);
	
	btn->setBackgroundSpriteForState(normal, Control::State::NORMAL);
	btn->setBackgroundSpriteForState(select, Control::State::SELECTED);
	btn->setBackgroundSpriteForState(hightlight, Control::State::HIGH_LIGHTED);
	btn->setBackgroundSpriteForState(disable, Control::State::DISABLED);
	
	
    LabelTTF *titleButton = LabelTTF::create(title, "AmericanTypewriter", 30);//添加文字
	titleButton->setAnchorPoint(Point(0.5f, 0.5f));
	titleButton->setPosition(Point(btn->getContentSize().width/2, btn->getContentSize().height/2));
	titleButton->setColor(Color3B::BLACK);//设置文字点击前的颜色
	titleButton->setTag(1000);
	btn->addChild(titleButton);

    return btn;
}
TableViewCell* HelloWorld::tableCellAtIndex(cocos2d::extension::TableView *table, ssize_t idx){
    
    TableViewCell *cell = table->dequeueCell();
    LabelTTF *label;
    
    if(cell == NULL){
        cell = TableViewCell::create();
        label = LabelTTF::create();
        label->setTag(2);
        cell->addChild(label);
        label->setFontSize(30);
        label->setAnchorPoint(Point(0,0));
    }
    else {
        label = (LabelTTF*)cell->getChildByTag(2);
    }
    
    label->setString(StringUtils::format("Label %ld",idx));
    
    return cell;
};
Пример #5
0
void PopupLayer::addPlayersLottery()
{
	for(int i=1;i<=30;i++)
	{
		if(this->getChildByTag(1000+i) != NULL)
		{
			this->removeChildByTag(1000+i);
		}
		
	}

	//Size winSize = Director::getInstance()->getWinSize();
	Size size = this->getContentSize();
	Size center =(winSize-size)/2;
	int j=0;
	for(auto it=players_vector.begin();it!=players_vector.end();it++)
	{
		RicherPlayer* player = dynamic_cast<RicherPlayer*>(*it);
		
		playerLotteryVector.clear();
		for(int i=0;i < player->lottery_vector.size();i++)
		{
			
			LabelTTF* labelLotteryNumber = LabelTTF::create(String::createWithFormat("%i",player->lottery_vector.at(i))->getCString(),"",15);
			labelLotteryNumber->setPosition(ccp( center.width+20+(i+1)*20, (winSize.height/2+30)+j*50));
			labelLotteryNumber->setColor(Color3B(255,100,100));
			labelLotteryNumber->setTag(1000+player->lottery_vector.at(i));
			playerLotteryVector.pushBack(labelLotteryNumber);
		}

		for(int i=0;i < playerLotteryVector.size();i++)
		{
			addChild(playerLotteryVector.at(i));	
		}
		j++;

	}
}
Пример #6
0
bool GamePlay::init() {
	if (!Layer::init()) {
		return false;
	}

	gameState = Ready;
	visibleSize = Director::getInstance()->getVisibleSize();
	getSoundMusic();

	//load game AI
	//init array number and computation
	int ARRAY_NUMBER[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
	arrNum = gameAI->randomNumber(ARRAY_NUMBER, SUM_NUM);
	for (int i = 0; i < SUM_NUM; i++) {
		arrNUM[i] = arrNum[i];
	}
	char s[SUM_COM] = "";
	//TODO change level
//	arrCOM = gameAI->randomComputation(s, SUM_COM,
//			GamePlay::instance()->getLevel() >= 2 ? 2 : 3);
	arrCOM = gameAI->randomComputation(s, SUM_COM, 2);
	for (int i = 0; i < SUM_COM; i++) {
		arrCOMPUTATE[i] = arrCOM[i];
	}
	for (int i = 0; i < SUM_COM / 2; i++) {
		tempResult[i] = INIT_FRAME;
	}

	int arr[GamePlay::instance()->getLevel()];
	int* arrayLevel = gameAI->randomLessNumber(arr,
			GamePlay::instance()->getLevel());

	//load background
	auto bg = Sprite::create("background.png");
	bg->setAnchorPoint(Vec2(0, 0));
	bg->setPosition(Vec2(0, 0));
	this->addChild(bg, -1);
	float rX = visibleSize.width / bg->getContentSize().width;
	float rY = visibleSize.height / bg->getContentSize().height;
	bg->setScaleX(rX);
	bg->setScaleY(rY);

	//show logo game
	Sprite *logoGame = Sprite::create("smalllogo.png");
	logoGame->setAnchorPoint(Vec2(0.0, 1.0));
	logoGame->setPosition(Vec2(PADDING, visibleSize.height - PADDING));
	logoGame->setTag(TAG_LOGO);
	logoGame->setScale(0.6f);
	this->addChild(logoGame);

	//load frame ready
	float baseY = logoGame->getPositionY()
			- logoGame->getBoundingBox().size.height - PADDING;
	float baseX = PADDING / 2;
	for (int i = 0; i < SUM_NUM; i++) {
		frameReady[i] = Sprite::create("frame.png");
		float width = frameReady[i]->getContentSize().width;
		float height = frameReady[i]->getContentSize().height;
		frameReady[i]->setTag(TAG_START_READY_POINT + i);
		frameReady[i]->setPositionX(baseX + 5.0 / 8.0 * i * width + width / 2);
		if (i % 2 == 0) {
			frameReady[i]->setPositionY(baseY - height / 2);
		} else {
			frameReady[i]->setPositionY(baseY - height);
		}
		this->addChild(frameReady[i]);
	}

	//create frame play
	float paddingY = 0;
	float paddingX = 0;
	for (int i = 0; i < SUM_NUM; i++) {
		float baseX = PADDING;
		framePlay[i] = TouchSprite::create("frame.png");
		framePlay[i]->setTag(TAG_FRAME_PLAY + i);
		paddingX = (visibleSize.width - PADDING * 4
				- framePlay[i]->getContentSize().width) / 3.0;
		framePlay[i]->setPositionX(
				PADDING + framePlay[i]->getContentSize().width / 2
						+ paddingX * (i % 3));

		float baseY = frameReady[0]->getPositionY();
		if (i % 3 == 0)
			paddingY = paddingX * ((int) i / 3 + 1);
		framePlay[i]->setPositionY(baseY - paddingY);
		framePlay[i]->score = 0;
		framePlay[i]->isFixed = false;
		for (int j = 0; j < GamePlay::instance()->getLevel(); j++) {
			if (arrNum[i] == arrayLevel[j]) {
				framePlay[i]->score = arrNum[i];
				//TODO
				framePlay[i]->isFixed = true;
				framePlay[i]->setDisplayFrame(
						SpriteFrame::create(
								"frame" + std::to_string(arrNum[i]) + ".png",
								framePlay[i]->getTextureRect()));
			}
		}
//		CCLog("frameplay[%d] = %d", i, framePlay[i]->score);
		this->addChild(framePlay[i]);
	}

	//load number button
	//TODO
	std::string name = "number";
	MoveTo* actionBy;
	int k = 0;
	for (int i = 0; i < SUM_NUM; i++) {
		numberBtn[i] = TouchSprite::create(
				name + std::to_string(i + 1) + ".png");
		numberBtn[i]->setTag(TAG_NUMBER + i);
		numberBtn[i]->setPositionY(visibleSize.height + 3 * PADDING);
		numberBtn[i]->setPositionX(frameReady[i]->getPositionX());
		numberBtn[i]->setZOrder(10);
		numberBtn[i]->isHidden = false;
		this->addChild(numberBtn[i]);
		actionBy = MoveTo::create(0.4, frameReady[i]->getPosition());
		auto easeAction = EaseBounceInOut::create(actionBy);

		for (int j = 0; j < GamePlay::instance()->getLevel(); j++) {
			if ((i + 1) == arrayLevel[j]) {
				numberBtn[i]->isHidden = true;
				numberBtn[i]->setVisible(false);
			}
		}

		if (numberBtn[i]->isHidden == false) {
			auto delay = DelayTime::create(0.2 * (k + 1));
			auto sequence = Sequence::create(delay, easeAction, nullptr);
			numberBtn[i]->runAction(sequence);
			k++;
		}
	}

	if (frameReady != NULL) {
		for (int i = 0; i < SUM_NUM; i++)
			frameReady[i]->setVisible(false);
	}

	//create result frame and equal character
	Sprite* frameEqual[SUM_COM / 2];
	Sprite* characterEqual[SUM_COM / 2];
	for (int i = 0; i < SUM_COM / 2; i++) {
		characterEqual[i] = Sprite::create("icon_equal.png");
		frameEqual[i] = Sprite::createWithTexture(frameReady[i]->getTexture());
		frameEqual[i]->setTag(TAG_FRAME_EQUAL + i);
		if (i % 2 == 0) {
			//frame equal
			frameEqual[i]->setPositionY(
					framePlay[SUM_NUM - 1]->getPositionY()
							+ paddingX * (2 - (int) i / 2));
			frameEqual[i]->setPositionX(
					framePlay[SUM_NUM - 1]->getPositionX() + paddingX);
			//character equal
			characterEqual[i]->setPositionY(
					framePlay[SUM_NUM - 1]->getPositionY()
							+ paddingX * ((int) i / 2));
			characterEqual[i]->setPositionX(
					framePlay[SUM_NUM - 1]->getPositionX() + paddingX / 2);
		} else {
			//frame equal
			frameEqual[i]->setPositionY(
					framePlay[SUM_NUM - 1]->getPositionY() - paddingX);
			frameEqual[i]->setPositionX(
					framePlay[SUM_NUM - 1]->getPositionX()
							- paddingX * (2 - (int) i / 2));
			//character equal
			characterEqual[i]->setPositionY(
					framePlay[SUM_NUM - 1]->getPositionY() - paddingX / 2);
			characterEqual[i]->setPositionX(
					framePlay[SUM_NUM - 1]->getPositionX()
							- paddingX * (2 - (int) i / 2));
		}
		this->addChild(frameEqual[i]);
		this->addChild(characterEqual[i]);
	}

	//position of character computation
	Sprite* plusSprite = Sprite::create("icon_plus.png");
	Sprite* minusSrite = Sprite::create("icon_minus.png");
	Sprite* mutiplySprite = Sprite::create("icon_multiply.png");
	Sprite* divideSprite = Sprite::create("icon_divide.png");

	for (int i = 0; i < SUM_COM; i++) {
		if (arrCOM[i] == '+')
			comBtn[i] = Sprite::createWithTexture(plusSprite->getTexture());
		else if (arrCOM[i] == '-')
			comBtn[i] = Sprite::createWithTexture(minusSrite->getTexture());
		else if (arrCOM[i] == '*')
			comBtn[i] = Sprite::createWithTexture(mutiplySprite->getTexture());
		else if (arrCOM[i] == '/')
			comBtn[i] = Sprite::createWithTexture(divideSprite->getTexture());
		this->addChild(comBtn[i]);
	}
	setPosCharacterBtn(comBtn, framePlay, paddingX);

	//calculate result
	result[0] = gameAI->calculate(arrNum[0], arrNum[1], arrNum[2], arrCOM[0],
			arrCOM[1]);
	result[1] = gameAI->calculate(arrNum[0], arrNum[3], arrNum[6], arrCOM[2],
			arrCOM[7]);
	result[2] = gameAI->calculate(arrNum[3], arrNum[4], arrNum[5], arrCOM[5],
			arrCOM[6]);
	result[3] = gameAI->calculate(arrNum[1], arrNum[4], arrNum[7], arrCOM[3],
			arrCOM[8]);
	result[4] = gameAI->calculate(arrNum[6], arrNum[7], arrNum[8], arrCOM[10],
			arrCOM[11]);
	result[5] = gameAI->calculate(arrNum[2], arrNum[5], arrNum[8], arrCOM[4],
			arrCOM[9]);
	gameAI->printArray(result, SUM_COM / 2);

	//set result to frameEqual
	for (int i = 0; i < SUM_COM / 2; i++) {
		resultLabel[i] = LabelTTF::create("00:00", "fonts/hlvgchac.ttf", 48);
		resultLabel[i]->setColor(Color3B(Color3B::RED));
		resultLabel[i]->setString(std::to_string(result[i]));
		resultLabel[i]->setPosition(frameEqual[i]->getPosition());
		this->addChild(resultLabel[i]);
	}

	//button pause
	Sprite* pauseGame = Sprite::create("pauseBtn.png");
	Sprite* pauseGame_press = Sprite::create("pauseBtn_press.png");
	MenuItemSprite* pauseBtn = MenuItemSprite::create(pauseGame,
			pauseGame_press, NULL, CC_CALLBACK_0(GamePlay::gamePause, this));
	Menu *menuPause = Menu::create(pauseBtn, nullptr);
	menuPause->setPosition(
			Vec2(
					visibleSize.width - PADDING
							- pauseBtn->getContentSize().width / 2,
					visibleSize.height - PADDING
							- pauseBtn->getContentSize().height / 2));
	menuPause->setTag(TAG_PAUSE_BTN);
	this->addChild(menuPause);

	//time in pause button
	LabelTTF *currenttime = LabelTTF::create("00:00", "fonts/hlvgchac.ttf", 40);
	Point timePoint = menuPause->getPosition();
	currenttime->setPosition(
			Vec2(timePoint.x - PADDING * 2, timePoint.y + 7.0 / 4.0 * PADDING));
	currenttime->setZOrder(10);
	currenttime->setColor(Color3B(Color3B::RED));
	currenttime->setTag(TAG_LABEL_COUNT_TIME);
	this->addChild(currenttime);

	std::string miniModeSprite = getLevelString(
			GamePlay::instance()->getLevel());
	Sprite* miniMode = Sprite::create("mini" + miniModeSprite + ".png");
	miniMode->setScale(0.5);
	miniMode->setPosition(
			Vec2(currenttime->getPositionX(),
					currenttime->getPositionY()
							- currenttime->getContentSize().height
							- PADDING / 2));
	this->addChild(miniMode);

	//board menu pause
	boardMenuPause = Sprite::create("board.png");
	boardMenuPause->setPosition(
			Vec2(visibleSize.width / 2,
					visibleSize.height
							+ boardMenuPause->getContentSize().height / 2
							+ PADDING));
	boardMenuPause->setZOrder(30);
	this->addChild(boardMenuPause);

	//button help of menu
	Sprite* helpbtn = Sprite::create("help1.png");
	Sprite* helpbtn_press = Sprite::create("help2.png");
	MenuItemSprite* helpBtn = MenuItemSprite::create(helpbtn, helpbtn_press,
	NULL, CC_CALLBACK_0(GamePlay::gameHelp, this));
	Menu *menuHelp = Menu::create(helpBtn, nullptr);
	menuHelp->setPosition(
			Vec2(boardMenuPause->getContentSize().width / 2,
					boardMenuPause->getContentSize().height
							- helpbtn->getContentSize().height));
	boardMenuPause->addChild(menuHelp);

	//button setting of menu
	Sprite* setbtn = Sprite::create("settings1.png");
	Sprite* setbtn_press = Sprite::create("settings2.png");
	MenuItemSprite* setBtn = MenuItemSprite::create(setbtn, setbtn_press, NULL,
			CC_CALLBACK_0(GamePlay::gameSetting, this));
	Menu *menuSetting = Menu::create(setBtn, nullptr);
	menuSetting->setPosition(
			Vec2(boardMenuPause->getContentSize().width / 2,
					menuHelp->getPositionY() - setbtn->getContentSize().height
							- PADDING));
	menuSetting->setTag(TAG_SETTING);
	boardMenuPause->addChild(menuSetting);

	//button quit of menu
	Sprite* quitbtn = Sprite::create("quit1.png");
	Sprite* quitbtn_press = Sprite::create("quit2.png");
	MenuItemSprite* quitBtn = MenuItemSprite::create(quitbtn, quitbtn_press,
	NULL, CC_CALLBACK_0(GamePlay::gameQuit, this));
	Menu *menuQuit = Menu::create(quitBtn, nullptr);
	menuQuit->setPosition(
			Vec2(menuSetting->getPositionX(),
					menuSetting->getPositionY()
							- quitbtn->getContentSize().height - PADDING));
	menuQuit->setTag(TAG_QUIT);
	boardMenuPause->addChild(menuQuit);

	//button replay, resume, share
	MenuItemImage* resumeBtn = MenuItemImage::create("menu_resume.png",
			"menu_resume.png", CC_CALLBACK_0(GamePlay::gameResume, this));
	auto menuResume = Menu::create(resumeBtn, nullptr);
	menuResume->setPosition(
			Vec2(menuSetting->getPositionX(),
					menuQuit->getPositionY()
							- resumeBtn->getContentSize().height - PADDING));
	boardMenuPause->addChild(menuResume);

	MenuItemImage* replayBtn = MenuItemImage::create("menu_replay.png",
			"menu_replay.png", CC_CALLBACK_0(GamePlay::gameReplay, this));
	auto menuReplay = Menu::create(replayBtn, nullptr);
	menuReplay->setPosition(
			Vec2(
					menuResume->getPositionX()
							- resumeBtn->getContentSize().width - PADDING,
					menuResume->getPositionY()));
	boardMenuPause->addChild(menuReplay);

	MenuItemImage* shareBtn = MenuItemImage::create("menu_share.png",
			"menu_share.png",
			CC_CALLBACK_0(GamePlay::gameShareCloseMenuPause, this));
	auto menuShare = Menu::create(shareBtn, nullptr);
	menuShare->setPosition(
			Vec2(
					menuResume->getPositionX()
							+ resumeBtn->getContentSize().width + PADDING,
					menuResume->getPositionY()));
	boardMenuPause->addChild(menuShare);

	auto event_listener = EventListenerTouchOneByOne::create();
	auto dispatcher = Director::getInstance()->getEventDispatcher();
	event_listener->setSwallowTouches(true);
	event_listener->onTouchBegan = CC_CALLBACK_2(GamePlay::onTouchBegan, this);
	event_listener->onTouchMoved = CC_CALLBACK_2(GamePlay::onTouchMoved, this);
	event_listener->onTouchEnded = CC_CALLBACK_2(GamePlay::onTouchEnded, this);
	dispatcher->addEventListenerWithSceneGraphPriority(event_listener, this);
	this->setKeypadEnabled(true);
	this->scheduleUpdate();
//	this->schedule(schedule_selector(GamePlay::update), 1.0f);
	gameState = Playing;
	return true;
}
Пример #7
0
FailScene::FailScene(void)
{
	Vec2 points[] = {	Vec2(0, 0), 
						Vec2(0, 140),
						Vec2(400, 140),
						Vec2(400, 0) };
	DrawNode* draw = DrawNode::create();
	//±³¾°
	draw->drawPolygon(points, 4, ColorUtil::getColor4F(0x00 , 0xAD , 0xFF, 0xFF),
								0, ColorUtil::getColor4F(0x00, 0xDA, 0xFF, 0xFF));

	this->addChild(draw);
	draw->setAnchorPoint(Point(.5, .5));
	draw->setPositionX(ScreenUtil::getCenter().x - 200);
	draw->setPositionY(ScreenUtil::getCenter().y - 140);

	Vec2 points2[] = {	Vec2(0, 0), 
						Vec2(0, 150),
						Vec2(230, 150),
						Vec2(230, 0) };
	DrawNode* draw2 = DrawNode::create();
	//±³¾°
	draw2->drawPolygon(points2, 4, ColorUtil::getColor4F(0x00 , 0xAD , 0xFF, 0xFF),
								0, ColorUtil::getColor4F(0x00, 0xDA, 0xFF, 0xFF));

	this->addChild(draw2);
	draw2->setAnchorPoint(Point(.5, .5));
	draw2->setPositionX(ScreenUtil::getCenter().x - 115);
	draw2->setPositionY(ScreenUtil::getCenter().y + 40);

	LabelTTF* scoreTxt = LabelTTF::create("Score:", "Arial", 45);
	scoreTxt->setAnchorPoint(Point(0, .5));
	scoreTxt->setPosition(Point(draw2->getPositionX() + 10, 
								draw2->getPositionY() + 110));
	this->addChild(scoreTxt);

	LabelTTF* bestScoreTxt = LabelTTF::create("Best:", "Arial", 45);
	bestScoreTxt->setAnchorPoint(Point(0, .5));
	bestScoreTxt->setPosition(Point(scoreTxt->getPositionX(), 
									draw2->getPositionY() + 50));
	this->addChild(bestScoreTxt);

	LabelTTF* scoreValTxt = LabelTTF::create("0", "Arial", 45);
	scoreValTxt->setPositionX(scoreTxt->getPositionX() + scoreTxt->getContentSize().width + 25);
	scoreValTxt->setPositionY(scoreTxt->getPositionY());
	scoreValTxt->setTag(scoreValTxtTag);
	this->addChild(scoreValTxt);

	LabelTTF* bestScoreValTxt = LabelTTF::create("0", "Arial", 45);
	bestScoreValTxt->setPositionX(scoreValTxt->getPositionX());
	bestScoreValTxt->setPositionY(bestScoreTxt->getPositionY());
	bestScoreValTxt->setTag(bestScoreValTxtTag);
	this->addChild(bestScoreValTxt);

	LabelTTF* replayTxt = LabelTTF::create("Replay", "Arial", 45);
	MenuItemLabel* replayBtn = MenuItemLabel::create(replayTxt);
	replayBtn->setTag(replayBtnTag);

	LabelTTF* shareTxt = LabelTTF::create("Share", "Arial", 45);
	MenuItemLabel* shareBtn = MenuItemLabel::create(shareTxt);

	Menu* menu = Menu::create(replayBtn, shareBtn,  NULL);
	menu->setPositionX(ScreenUtil::getCenter().x);
	menu->setPositionY(ScreenUtil::getCenter().y - 70);
	menu->alignItemsHorizontallyWithPadding(50);
	menu->setTag(menuTag);
	this->addChild(menu);
}
Пример #8
0
// on "init" you need to initialize your instance
bool Tutorial::init()
{
    //サイズ取得を行う
    origin			= Director::getInstance()->getVisibleOrigin();		//使用端末の(0,0)地点
	visibleSize		= Director::getInstance()->getVisibleSize();		//使用端末の画面サイズ

	this->setTouchMode(kCCTouchesOneByOne);								// シングルタッチモードにする
    this->setTouchEnabled(true);										// タッチを有効にする(内部的にEventDispatcherに登録される)

    auto keyboardListener = EventListenerKeyboard::create();
    keyboardListener->onKeyReleased = CC_CALLBACK_2(Tutorial::onKeyReleased, this);
    this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(keyboardListener, this);

    // 背景を生成
	UserDefault* userDefault = UserDefault::sharedUserDefault();
	int wk_flag = userDefault->getIntegerForKey(key_tutorialFlag, 1);

	Sprite* pBG;
	if (wk_flag == 3) {
		pBG = Sprite::create("help_1.png");
	} else {

//	    // NEXTボタン
//	    MenuItemImage* pSaisei = MenuItemImage::create("button_saisei.png",
//											 "button_saisei.png",
//											 CC_CALLBACK_1(Tutorial::tapSaiseiMenu, this));
//	    pSaisei->setPosition(Point(visibleSize.width * 0.5, origin.y + 220));
//		Menu* pMenu = Menu::create(pSaisei, NULL);
//		pMenu->setPosition(Point::ZERO);
//		pMenu->setTag(kTag_Saisei);
//		this->addChild(pMenu,2);

		//ターゲット
		Node* pTarget = Sprite::create("target_0.png");
		pTarget->setPosition(Point(pTarget->getContentSize().width+50.0, visibleSize.height * 0.80));
		pTarget->setTag(tagTargetImg);
		this->addChild(pTarget,2);
		Node* pTarget1 = Sprite::create("target_1.png");
		pTarget1->setPosition(Point(pTarget->getContentSize().width+10.0, visibleSize.height * 0.80));
		pTarget1->setTag(tagTargetImgSub1);
		this->addChild(pTarget1,1);
		pTarget1 = Sprite::create("target_1.png");
		pTarget1->setPosition(Point(pTarget->getContentSize().width+90.0, visibleSize.height * 0.80));
		pTarget1->setRotation(180);
		pTarget1->setTag(tagTargetImgSub2);
		this->addChild(pTarget1,1);

		//矢印表示
		Node* pArrow = Sprite::create("back_blue.png");
		pArrow->setPosition(Point(visibleSize.width-80, visibleSize.height * 0.80));
		pArrow->setTag(tagArrow);
		this->addChild(pArrow,9);
		Node* pArrow1 = Sprite::create("13.png");
		Size bgSize = pArrow->getContentSize();
		pArrow1->setPosition(Point(bgSize.width * 0.5, bgSize.height * 0.5));
		pArrow->addChild(pArrow1,10);

		pArrow->runAction(CCRepeatForever::create(Blink::create(5,5)));

		//メッセージ
		Node* pMsg = Sprite::create("help_msg1.png");
		pMsg->setPosition(Point(visibleSize.width-150, visibleSize.height * 0.80-100));
		pMsg->setTag(tagMsg);
		this->addChild(pMsg,2);

		pMsg = Sprite::create("help_msg3.png");
		pMsg->setPosition(Point(visibleSize.width/2 , origin.y + 200));
		pMsg->setTag(tagTap2);
		this->addChild(pMsg,2);

		LabelTTF* arrowLabel = LabelTTF::create("タップしてね", "Arial", 40);
		arrowLabel->setColor(ccc3(0, 0, 0));
		arrowLabel->setPosition(Point(visibleSize.width/2 , origin.y + 200));
		arrowLabel->setTag(tagTap);
		this->addChild(arrowLabel,3);
		arrowLabel->runAction(CCRepeatForever::create(Blink::create(5,7)));


		pBG = Sprite::create("Tutorial.png");
	}
    pBG->setPosition(Point(visibleSize.width * 0.5, visibleSize.height * 0.5));
    this->addChild(pBG);


    return true;
}
Пример #9
0
void Tutorial::onTouchEnded(Touch* touch, Event* event)
{

	UserDefault* userDefault = UserDefault::sharedUserDefault();
	int wk_flag = userDefault->getIntegerForKey(key_tutorialFlag, 1);

	if (wk_flag < 3) {


		Node* pArrow = this->getChildByTag(tagArrow);
		Node* pYubi;
		Node* pMsg;
		LabelTTF* arrowLabel;
		switch (scene_flag){
		case 0:
			//アニメーション停止
			pArrow->stopAllActions();
			pArrow->runAction(Show::create());
			pArrow->runAction(MoveTo::create(2, ccp(120.0, visibleSize.height * 0.80)));

			// 	メッセージ削除
			pMsg = this->getChildByTag(tagMsg);
			pMsg->removeFromParentAndCleanup(true);
			pMsg = this->getChildByTag(tagTap);
			pMsg->removeFromParentAndCleanup(true);
			pMsg = this->getChildByTag(tagTap2);
			pMsg->removeFromParentAndCleanup(true);

			//スワイプアニメーション追加
			pYubi = Sprite::create("yubi.png");
			pYubi->setPosition(Point(visibleSize.width-120, visibleSize.height * 0.80-200));
			pYubi->setRotation(120);
			pYubi->setTag(tagYubi);
			this->addChild(pYubi,2);
			pYubi->runAction(Sequence::create(MoveTo::create(1, ccp(120.0, visibleSize.height * 0.80-200)),MoveTo::create(0.7, ccp(120.0, visibleSize.height * 0.4)),NULL));

			scene_flag++;

			this->scheduleOnce(schedule_selector(Tutorial::msg2), 2);

			break;
		case 1:
			//アニメーションキャンセル
			this->unschedule(schedule_selector(Tutorial::msg2));

			//矢印を所定の位置へ移動
			pArrow->stopAllActions();
			pArrow->setPosition(Point(120.0, visibleSize.height * 0.80));

			//yubiを所定の位置へ移動
			pYubi  = this->getChildByTag(tagYubi);
			pYubi->stopAllActions();
			pYubi->setPosition(Point(120.0, visibleSize.height * 0.4));
			pYubi->runAction(RotateBy::create(0.5f, -90.0f));

			//メッセージ表示
			pMsg = Sprite::create("help_msg2.png");
			pMsg->setPosition(Point(280, visibleSize.height * 0.80-150));
			pMsg->setTag(tagMsg);
			this->addChild(pMsg,2);

			pMsg = Sprite::create("help_msg3.png");
			pMsg->setPosition(Point(visibleSize.width/2 , origin.y + 200));
			pMsg->setTag(tagTap2);
			this->addChild(pMsg,2);

			arrowLabel = LabelTTF::create("タップしてね", "Arial", 40);
			arrowLabel->setColor(ccc3(0, 0, 0));
			arrowLabel->setPosition(Point(visibleSize.width/2 , origin.y + 200));
			arrowLabel->setTag(tagTap);
			this->addChild(arrowLabel,3);
			arrowLabel->runAction(CCRepeatForever::create(Blink::create(5,7)));

			scene_flag++;

			break;
		case 2:
			if (wk_flag == 1) {
				Scene* gameScene = (Scene*)TitleScene::create();
				Director::getInstance()->replaceScene(gameScene);
			} else if (wk_flag == 2) {
				//相手レベル記録
				UserDefault* userDefault = UserDefault::sharedUserDefault();
				userDefault->setIntegerForKey(key_playEnemyLv, 1);

				// ゲーム画面の表示
				Scene* scene = HelloWorld::createScene();
				TransitionFlipX* tran = TransitionFlipX::create(0.2, scene);
				Director::sharedDirector()->replaceScene(tran);
			}
		}

	} else {
		if (wk_count > 3) {
		    Scene* scene = PowerUp::createScene();
		    TransitionFlipX* tran = TransitionFlipX::create(1, scene);
		    Director::sharedDirector()->replaceScene(tran);
		} else {
			wk_count = wk_count + 1;
			Sprite* pBG = Sprite::create(String::createWithFormat("help_%d.png", wk_count)->getCString());
		    pBG->setPosition(Point(visibleSize.width * 0.5, visibleSize.height * 0.5));
		    this->addChild(pBG);
		}
	}

}
bool QuestionContainerSprite::init()
{
    if (Sprite::init())
    {
        //Add label
        LabelTTF* label = LabelTTF::create("Answer 1", "Arial", 12);
        label->setTag(100);

        //Add the background
        Size size = Director::getInstance()->getWinSize();
        Sprite* corner = Sprite::create("Images/bugs/corner.png");

        int width = size.width * 0.9f - (corner->getContentSize().width * 2);
        int height = size.height * 0.15f  - (corner->getContentSize().height * 2);
        LayerColor* layer = LayerColor::create(Color4B(255, 255, 255, 255 * .75), width, height);
        layer->setPosition(Point(-width / 2, -height / 2));

        //First button is blue,
        //Second is red
        //Used for testing - change later
        static int a = 0;
        
        if (a == 0)
            label->setColor(Color3B::BLUE);
        else
        {
            log("Color changed");
            label->setColor(Color3B::RED);
        }
        a++;
        addChild(layer);

        corner->setPosition(Point(-(width / 2 + corner->getContentSize().width / 2), -(height / 2 + corner->getContentSize().height / 2)));
        addChild(corner);

        Sprite* corner2 = Sprite::create("Images/bugs/corner.png");
        corner2->setPosition(Point(-corner->getPosition().x, corner->getPosition().y));
        corner2->setFlipX(true);
        addChild(corner2);

        Sprite* corner3 = Sprite::create("Images/bugs/corner.png");
        corner3->setPosition(Point(corner->getPosition().x, -corner->getPosition().y));
        corner3->setFlipY(true);
        addChild(corner3);

        Sprite* corner4 = Sprite::create("Images/bugs/corner.png");
        corner4->setPosition(Point(corner2->getPosition().x, -corner2->getPosition().y));
        corner4->setFlipX(true);
        corner4->setFlipY(true);
        addChild(corner4);

        Sprite* edge = Sprite::create("Images/bugs/edge.png");
        edge->setScaleX(width);
        edge->setPosition(Point(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), corner->getPosition().y));
        addChild(edge);
        
        Sprite* edge2 = Sprite::create("Images/bugs/edge.png");
        edge2->setScaleX(width);
        edge2->setPosition(Point(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), -corner->getPosition().y));
        edge2->setFlipY(true);
        addChild(edge2);

        Sprite* edge3 = Sprite::create("Images/bugs/edge.png");
        edge3->setRotation(90);
        edge3->setScaleX(height);
        edge3->setPosition(Point(corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2)));
        addChild(edge3);

        Sprite* edge4 = Sprite::create("Images/bugs/edge.png");
        edge4->setRotation(270);
        edge4->setScaleX(height);
        edge4->setPosition(Point(-corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2)));
        addChild(edge4);

        addChild(label);
        return true;
    }

    return false;
}