Пример #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
void CCActionTest::testMove(Object *sender)
{
	log("testMove");
	
	LabelTTF *label = createTestLabel("Hello");

	MoveTo *move = MoveTo::create(3, Point(300, 300));
	
	label->runAction(move);
	
	hideMenu();
}
Пример #3
0
void BaseScene::addScore(int _score, Vec2 pos){
	LabelTTF* label = LabelTTF::create(MyTool::num2str(_score), "", 50);
	label->setPosition(pos);
	label->setColor(Color3B(255,0,0));
	label->setName("ASL"); // AddAcoreLabel
	addChild(label, 3);
	float dt = scoreLabelPos.distance(pos) / 200;
	dt = (dt > 0.5) ? 0.5 : dt;
	dt = (dt < 0.3) ? 0.3 : dt;
	ScaleTo* st = ScaleTo::create(dt, 0.4);
	MoveTo* mt = MoveTo::create(dt, scoreLabelPos);
	Spawn* ac = Spawn::create(st, mt, nullptr);

	/* callFunc是一个函数,没法用到函数外的局部变量,虽然用匿名函数,编译器不报错,但是数据是未经初始化的  */
	actiondata.intdata = _score;  
	//actiondata.pointdata = this;///虽然能传入,但当前一个没删除时,又触发了,则前一个内存泄露
	Sequence* allac = Sequence::create(ac, CallFuncN::create([&](Node* sender){
		((BaseScene*)(sender->getParent()))->removeChild(sender);
		score += actiondata.intdata; 
		lock--;
	}), nullptr);
	lock++;
	label->runAction(allac);
}
Пример #4
0
void Boss_Monster::LoseLife(int atk)
{
	this->hp -= atk;
	if (hp < 0)
	{
		hp = 0;
	}

	//É˺¦Êä³ö·´À¡
	LabelTTF* hurt = LabelTTF::create(String::createWithFormat("Hit %d", atk)->getCString(), "arial", 36);
	hurt->setColor(Color3B(255, 0, 0));
	hurt->setPosition(this->getPositionX() + 50, this->getPositionY());

	auto act = Sequence::create(Blink::create(0.8f, 1),
		CallFunc::create(([hurt](void){
		hurt->setVisible(false);
		hurt->removeFromParentAndCleanup(true);
	})), nullptr);

	this->getParent()->addChild(hurt);
	hurt->runAction(act);

	return;
}
Пример #5
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;
}
Пример #6
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);
		}
	}

}