//
// FadeIn
//
CCFadeIn* CCFadeIn::create(float d)
{
	CCFadeIn* pAction = new CCFadeIn();

	pAction->initWithDuration(d);
 	pAction->autorelease();

	return pAction;
}
//
// FadeIn
//
CCFadeIn* CCFadeIn::actionWithDuration(ccTime d)
{
	CCFadeIn* pAction = new CCFadeIn();

	pAction->initWithDuration(d);
 	pAction->autorelease();

	return pAction;
}
CCFiniteTimeAction* BYGameScene::createGoalLabelSpawn() {
    
    CCFadeIn *fadeIn = CCFadeIn::create(255);
    fadeIn->setDuration(BYGoalLabelAnimetionInterval);
    
    CCRotateBy *rotBY = CCRotateBy::create(BYGoalLabelFreezeAnimationInterval,
                                           360 * BYGoalLabelRotatesCount);
    
    CCScaleBy *scaleBy = CCScaleBy::create(BYGoalLabelFreezeAnimationInterval,
                                           1 / BYGoalLabelScaleBy);
    
    return CCSpawn::create(fadeIn, rotBY, scaleBy, NULL);
}
void MonsterLayer::flickFinished(CCNode* sender){
    CCLog("フリック終わったよ");
    
    //フリック音
    effectsound(4);
    
    const char *abc = "";
    
    
       CCLog("ラベルの文字を読み込むよ");
 
     
    /*
     //CCSize size = CCDirector::sharedDirector()->getWinSize();
     //$BC18l%i%Y%k$NJ8;z$r<hF@(B
     string str(flickLabel->getString());
     //$B:G=i$NJ8;z$r<hF@(B
     str.substr(0,2);
     // CCLog("%s",str.substr(0,1).c_str());
     cout << "文字数は" << str.size() << endl;
     CCLog("文字数は%s",str.substr(str.size()/2,2).c_str());
     //$B%(%G%#%C%H%\%C%/%9$NJ8;z$r<hF@(B
     */
    string str = wordLabel->getString();
   
    
   
     CCString *hoge1 = CCString::create(str.substr(0,3).c_str());
     CCString *hoge2 = CCString::create(flickLabel->getString());
     CCString *hoge3 = CCString::create(str.substr(str.size()-3,3).c_str());
    
    //二つのラベルに記入された文字を照合します。日本語は3byteを想定しています。String型で文字を一文字ずつ取り出します。
      CCLog("文字の照合を始めるよ");
    if (hoge1->isEqual(hoge2) && hoge3->isEqual(hoge2) && str.size()==3) {
          CCLog("配列を作るよ");
        
        int i = rand()%14;
        char    mtxary[][70]   = {"まうす","いわさきくん","さかもとさん", "わーい", "ほりくん","しろとくろ","おいういう","らいと","わーい","やさいふそく","すーん","かわいい","えいゆ","いけめん"};
        //CCSize size = CCDirector::sharedDirector()->getWinSize();
        
       
        wordLabel->setString(mtxary[i]);
        flickLabel->setString(abc);
        q=0;
        
        CCSprite* enemy = (CCSprite*)this->getChildByTag(666);
        
        this->m_points +=1;
        
        // スコアポイントのラベルを取得
        CCLabelTTF* label = (CCLabelTTF *)this->getChildByTag(39);
        // intからCCStringに変換
        CCString* points = CCString::createWithFormat("%d", this->m_points);
        // スコアポイントの表示を更新
        label->setString(points->getCString());
        //敵を倒すと頻度が上がる
        enemyR -=0.1;
        
        //敵の存在意義を・・・説きます!(敵が現れてからインスタンス作成)
        if (!(enemy==NULL)) {
            //砲弾の動き
            CCSprite* face = CCSprite::create("kao.png");
            CCSize size = CCDirector::sharedDirector()->getWinSize();
            face->setPosition(ccp(size.width/2,(size.height/2)+100));
            CCMoveTo *faceaction = CCMoveTo::create(0.1f,ccp(enemy->getPosition().x,enemy->getPosition().y));
            CCFadeOut *fadeout = CCFadeOut::create(0.1f);
            face->runAction(CCSequence::create(faceaction,fadeout,NULL));
            this->addChild(face,30);
        
        
        //アニメーション 消滅アクション
        CCSprite *metu = CCSprite::create("小爆発.png");
        metu->setScale(1.0);
        CCFadeIn *killin = CCFadeIn::create(0.1f);
        metu->setPosition(ccp(enemy->getPosition().x,enemy->getPosition().y));
        metu->runAction(killin);
        CCDelayTime *delay = CCDelayTime::create(0.1f);
        CCActionInterval *reverse = killin->reverse();
        metu->runAction(CCSequence::create(killin,delay,reverse,NULL));
        this->addChild(metu,40);
        }
        //効果音
        effectsound(3);
        this->removeChild(enemy);
        
 CCLog("全文字消えました");
    
     
    }else if (hoge1->isEqual(hoge2)) {
        CCLog("一文字消えました");
         q +=3;
         wordLabel->setString(str.substr(q,str.size()-q).c_str());
         flickLabel->setString(abc);
         q=0;
     }
     else{
         flickLabel->setString(abc);
         CCLog("まちがい");
         
     }
  
         CCLog("文字を照合した");
}