最难游戏代码续4_skybeauty_新浪博客

 

#ifndef __rentiancun__LoadingScene__

#define __rentiancun__LoadingScene__

#include "cocos2d.h"


using namespace cocos2d;


#include <iostream>

typedef enum

{

    TargetSceneINVALID = 0,

    TargetSceneGameModeScene,

    TargetSceneGameSceneBScene,

    TargetSceneInstructionScene,

    TargetSceneGameSceneScene,

    TargetSceneGame2Scene,

    TargetSceneGameChooseScene,

    TargetSceneScoreScene,

    TargetSceneScore1Scene,

    TargetSceneWin1Scene,

    TargetSceneWin2Scene,

    

   

   

    

    

}TargetScenes;

class Loadingscene:public CCScene

{

private:

   TargetScenes target;

   CCSprite * loading;

   CCLabelTTF*label;

   CCLabelTTF *label1;

   CCLabelTTF * label2;


public:

   bool init(TargetScenes scene,int tag);

   static Loadingscene *creat(TargetScenes scene,int tag);

   void update(float dt);

   void action(CCLabelTTF*lab);

   virtual~Loadingscene();

    

};



#endif


#include "Loadingscene.h"


#include "GameMode.h"

#include "GameScene2.h"

#include "Instruction.h"

#include "GameScene.h"


#include "GameChoose.h"

#include "FailBoy.h"

#include "Win.h"

bool Loadingscene::init(TargetScenes scene,int tag)

{

    CCSize size = CCDirector::sharedDirector()->getWinSize();

   if(!CCScene::init())

    {

        return false;

    }

   target = scene;

   if(tag==0)

    {

        loading = CCSprite::create("loading_bg-iphone4.jpg");

    

    }

   else if (tag==1)

    {

        

        loading = CCSprite::create("select_bg01-iphone4.jpg");

        label = CCLabelTTF::create("多次", "MarkerFelt-Thin", 30);

       label->setPosition(ccp(size.width*0.5,size.height*0.7));

       this->action(label);

        

        label1 = CCLabelTTF::create("掌掴", "MarkerFelt-Thin", 30);

       label1->setPosition(ccp(size.width*0.5,size.height*0.5));

       this->action(label1);

        

       label2 = CCLabelTTF::create("!", "MarkerFelt-Thin", 30);

       label2->setPosition(ccp(size.width*0.5,size.height*0.3));

       this->action(label2);

        

       

        

        

       CCLabelTTF * label3 = CCLabelTTF::create("STAGE 1", "MarkerFelt-Thin", 20);

        label3->setPosition(ccp(size.width-label3->getContentSize().width,size.height-label3->getContentSize().height));

       this->addChild(label3,1);

        label3->setColor(ccBLACK);


        

    }

   else if(tag==2)

    {

        loading = CCSprite::create("select_bg01-iphone4.jpg");

        label = CCLabelTTF::create("炸弹", "MarkerFelt-Thin", 30);

       label->setPosition(ccp(size.width*0.5,size.height*0.7));

        

       this->action(label);

        label1 = CCLabelTTF::create("恐慌", "MarkerFelt-Thin", 30);

       label1->setPosition(ccp(size.width*0.5,size.height*0.5));

       this->action(label1);

        

        

       label2 = CCLabelTTF::create("!", "MarkerFelt-Thin", 30);

       label2->setPosition(ccp(size.width*0.5,size.height*0.3));

       this->action(label2);

       

             

       CCLabelTTF * label3 = CCLabelTTF::create("STAGE 2", "MarkerFelt-Thin", 30);

        label3->setPosition(ccp(size.width-label3->getContentSize().width,size.height-label3->getContentSize().height));

        label3->setColor(ccBLACK);

       this->addChild(label3,1);

                   

    }

   else if(tag == 3)

    {

        loading = CCSprite::create("FBrank_bg-iphone4.jpg");

        CCLabelTTF * lab = CCLabelTTF::create("正在计算分数……", "MarkerFelt-Thin", 30);

        lab->setPosition(ccp(size.width*0.5, size.height*0.5));

       this->addChild(lab,1);

    }

    

    

   loading->setPosition(ccp(size.width/2, size.height/2));

   this->addChild(loading,0);


    

    this->schedule(schedule_selector(Loadingscene::update), 0.7f);

    

    return true;

    

    

}


Loadingscene* Loadingscene::creat(TargetScenes scene,int tag)

{

    Loadingscene *pRet = new Loadingscene();

   if(pRet && pRet->init(scene,tag))

    {

        pRet->autorelease();

       return pRet;

    }

   else

    {

       delete pRet;

        pRet = NULL;

       return NULL;

    }

    

    

}

void Loadingscene::update(float dt)

{

    this->unscheduleUpdate();

    

   switch (target)

    {

        case TargetSceneGameModeScene:

        {

           CCDirector::sharedDirector()->replaceScene(GameMode::scene());

           break;

        }

                    

        case TargetSceneGameSceneBScene:

        {

            CCDirector::sharedDirector()->replaceScene(GameSceneB::scene());

           break;

        }

        case TargetSceneInstructionScene:

        {

            CCDirector::sharedDirector()->replaceScene(Instruction::scene(2));

           break;

        }

        case TargetSceneGame2Scene:

        {

            CCDirector::sharedDirector()->replaceScene(Instruction::scene(1));

           break;

        }

        case TargetSceneGameSceneScene:

        {

            CCDirector::sharedDirector()->replaceScene(GameScene::scene());

           break;

        }

        case TargetSceneGameChooseScene:

        {

            CCDirector::sharedDirector()->replaceScene(GameChoose::scene());

           break;

        }

        case TargetSceneScoreScene:

        {

            CCDirector::sharedDirector()->replaceScene(FailBoy::scene(2));

           break;

        }

        case TargetSceneScore1Scene:

        {

           

            CCDirector::sharedDirector()->replaceScene(FailBoy::scene(1));

           break;

        }

        case TargetSceneWin1Scene:

        {

            

            CCDirector::sharedDirector()->replaceScene(Win::scene(1));

            

           break;

        }

        case TargetSceneWin2Scene:

        {

            CCDirector::sharedDirector()->replaceScene(Win::scene(2));

           break;

        }

            

       default:

           break;

    }

}

//控制字体动画

void Loadingscene::action(CCLabelTTF *lab)

{

      this->addChild(lab,1);

   

   CCJumpBy * action1 = CCJumpBy::create(0.8, ccp(0, CCRANDOM_0_1()*20), CCRANDOM_0_1()*20, 3);

    

   CCSequence * sequence1 = CCSequence::create(action1,action1->reverse(),NULL);

        lab->runAction(sequence1);

}

Loadingscene::~Loadingscene()

{

    this->removeAllChildren();

}




 

#ifndef __HardGame__InstantFail__

#define __HardGame__InstantFail__


#include "cocos2d.h"


class InstantFail : public cocos2d::CCLayer

{

public:

   virtual bool init(int tag);

   static cocos2d::CCScene* scene(int tag);//

   static InstantFail*create(int tag);

   virtual~InstantFail();

   

    

private:

   void retry();

   void BackBegin();

   int tag;

    

    

};


#endif



#include "InstantFail.h"

#include "GameChoose.h"

#include "SimpleAudioEngine.h"

#include "FailBoy.h"

#include "LoadingScene.h"

using namespace cocos2d;

using namespace CocosDenshion;


CCScene* InstantFail::scene(int tag)

{

   CCScene* scene = CCScene::create();

   InstantFail* layer = InstantFail::create( tag);

    scene->addChild(layer);

   return scene;

    

}


bool InstantFail::init(int tag)

{

   if ( !CCLayer::init() )

    {

        return false;

    }

   this->tag = tag;

    CCSize size = CCDirector::sharedDirector()->getWinSize();

    

   //背景

    CCSprite* sp = CCSprite::create("Instant_bg-iphone4.jpg");

    

    sp->setPosition(ccp(size.width*0.5, size.height*0.5));

    

   addChild(sp,0);

    

    

    CCMenuItemImage* itemBack = CCMenuItemImage::create("fail_button01-iphone4.png","fail_button01-iphone4.png",this,menu_selector(InstantFail::BackBegin));

    itemBack->setPosition(ccp(size.width* 0.15,size.height*0.85));

    

    CCMenuItemImage* itemRe = CCMenuItemImage::create("arcade_button06-iphone4.png","arcade_button06-iphone4.png",this,menu_selector(InstantFail::retry));

    itemRe->setPosition(ccp(size.width*0.5,size.height*0.13));

    

   CCMenu* menu = CCMenu::create(itemBack,itemRe,NULL);

    menu->setPosition(CCPointZero);

   addChild(menu,2);

    

   if (tag==1)

    {

        int n = CCUserDefault::sharedUserDefault()->getIntegerForKey("count");

       if(n>38)

        {

            n=38;

        }

        CCString* s = CCString::createWithFormat("失败!!!您掌掴%d\n请掌掴恰好37,\n然后点击完成。",n);

       CCLabelTTF * label = CCLabelTTF::create(s->getCString(), "Helvetica", 18);

       this->addChild(label);

        label->setPosition(ccp(size.width*0.5, size.height*0.6));

       

    

    }

   else if(tag==2)

    {        

        CCLabelTTF * label = CCLabelTTF::create("太慢了!\n在炸弹刚要到达0.00秒时\n停止它们!", "Helvetica", 20);

       this->addChild(label);

        label->setPosition(ccp(size.width*0.5, size.height*0.6));

        

    }



    

    return true;

}

InstantFail * InstantFail::create(int tag)

{

    InstantFail *pRet = new InstantFail();

   if (pRet&&pRet->init(tag))

    {

        pRet->autorelease();

       return pRet;

    }

   else

    {

        CC_SAFE_RELEASE_NULL(pRet);

       return NULL;

    }

    

}



void InstantFail::retry()

{

    

    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("gen_click.mp3");

   if (tag==1)

    {

        Loadingscene * s = Loadingscene::creat(TargetSceneGame2Scene, 1);

        CCDirector::sharedDirector()->replaceScene(s);

    }

   else if(tag==2)

    {

        Loadingscene * s = Loadingscene::creat(TargetSceneInstructionScene, 2);

        CCDirector::sharedDirector()->replaceScene(s);

    }

    

    

}

void InstantFail::BackBegin()

{

    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("gen_click.mp3");


   

   

        Loadingscene * s = Loadingscene::creat(TargetSceneGameChooseScene, 0);

        CCDirector::sharedDirector()->replaceScene(s);

          

}

InstantFail::~InstantFail()

{

    this->removeAllChildren();

}


 

#ifndef __HardGame__FailBoy__

#define __HardGame__FailBoy__


#include <iostream>

#include "cocos2d.h"

using namespace cocos2d;

class FailBoy : public cocos2d::CCLayer

{

public:

   virtual bool init(int tag);

   static CCScene* scene(int tag);

   static FailBoy*create(int tag);

    ~FailBoy();


   

private:

void BackBegin();

void LockDelay();

void ScreamDelay();

 void retry();

   int tag;

};

#endif



#include "FailBoy.h"

#include "SimpleAudioEngine.h"

#include "GameScene2.h"

#include "LoadingScene.h"

using namespace cocos2d;

using namespace CocosDenshion;


CCScene* FailBoy::scene(int tag)

{

   CCScene* scene = CCScene::create();

   FailBoy* layer = FailBoy::create(tag);

    scene->addChild(layer);

   return scene;

    

}

bool FailBoy::init(int tag)

{

   if ( !CCLayer::init() )

    {

        return false;

    }

    

    CCSize size = CCDirector::sharedDirector()->getWinSize();

    

   //背景

    CCSprite* sp = CCSprite::create("arcade_bg-iphone4.jpg");

    

    sp->setPosition(ccp(size.width*0.5, size.height*0.5));

    

   addChild(sp,0);

   this->tag = tag;

    

    //boy

    CCSprite* boy = CCSprite::create("fail_boy-iphone41.png");

    boy->setPosition(ccp(size.width*0.5, size.height* 1.2));

   CCMoveTo*boyMove = CCMoveTo::create(0.2, ccp(size.width*0.5, size.height*0.3));

    boy->runAction(boyMove);

   addChild(boy,1);

    

    //栏杆Langan

    CCSprite* Langan = CCSprite::create("fail_prison-iphone4.png");

    Langan->setPosition(ccp(size.width*0.5, size.height*3.5));

   CCMoveTo* langanMove = CCMoveTo::create(0.6, ccp(size.width*0.5, size.height*0.5));

    Langan->runAction(langanMove);

   addChild(Langan,2);

    //Back

    CCMenuItemImage* itemBack = CCMenuItemImage::create("fail_button01-iphone4.png","fail_button01-iphone4.png",this,menu_selector(FailBoy::BackBegin));

    itemBack->setPosition(ccp(20,270));

    //排行榜

    CCMenuItemImage* itemPh = CCMenuItemImage::create("fail_button02-iphone4.png","fail_button02-iphone4.png",this,menu_selector(FailBoy::retry));

    itemPh->setPosition(ccp(100,270));

    

    

    //replay

    CCMenuItemImage* itemRe = CCMenuItemImage::create("arcade_button06-iphone4.png","arcade_button06-iphone4.png",this,menu_selector(FailBoy::retry));

    itemRe->setPosition(ccp(130,0));

   CCMenu* menu = CCMenu::create(itemBack,itemRe,itemPh,NULL);

    menu->setPosition(CCPointZero);


    

   //

    CCSprite* lock = CCSprite::create("fail_kanban-iphone4.png");

    lock->setPosition(ccp(size.width*0.5, size.height*3.5));

   CCMoveTo* lockMove = CCMoveTo::create(1, ccp(size.width*0.5-2, size.height*0.5));

    lock->runAction(lockMove);

   addChild(lock,3);

    lock-> addChild(menu,3);

   


    this->scheduleOnce(schedule_selector(FailBoy::LockDelay),0.6f);

    this->scheduleOnce(schedule_selector(FailBoy::ScreamDelay),0.7f);

   if (tag==1)

    {

        int n = CCUserDefault::sharedUserDefault()->getIntegerForKey("sc");

        int m = CCUserDefault::sharedUserDefault()->getIntegerForKey("cs");

        CCString * s = CCString::createWithFormat("您的得分:%d.%dms\n闯关要求:<10.00ms",n,m);

       CCLabelTTF * label = CCLabelTTF::create(s->getCString(), "Helvetica", 15);

        lock->addChild(label,4);

        label->setPosition(ccp(lock->getContentSize().width*0.5, lock->getContentSize().height*0.5));

    }

   else

    {

        float n = CCUserDefault::sharedUserDefault()->getFloatForKey("score");

        CCString * s = CCString::createWithFormat("您的得分:%.2fms\n闯关要求:<0.5ms",n/9);

       CCLabelTTF * label = CCLabelTTF::create(s->getCString(), "Helvetica", 15);

        lock->addChild(label,4);

        label->setPosition(ccp(lock->getContentSize().width*0.5, lock->getContentSize().height*0.5));

    }

   

    return true;

}

FailBoy*FailBoy::create(int tag)

{

   FailBoy * pRet = new FailBoy();

   if (pRet&&pRet->init( tag))

    {

        pRet->autorelease();

       return pRet;

    }

   else

    {

        CC_SAFE_RELEASE_NULL(pRet);

       return NULL;

    }

}


void FailBoy::BackBegin()

{

    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("gen_click.mp3");

    

           Loadingscene * s = Loadingscene::creat(TargetSceneGameChooseScene, 0);

        CCDirector::sharedDirector()->replaceScene(s);

    

   

}

void FailBoy::retry()

{

    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("gen_click.mp3");

   if (tag==1)

    {

        Loadingscene * s = Loadingscene::creat(TargetSceneGame2Scene, 1);

        CCDirector::sharedDirector()->replaceScene(s);

    }

   else if(tag==2)

    {

        Loadingscene * s = Loadingscene::creat(TargetSceneInstructionScene, 2);

        CCDirector::sharedDirector()->replaceScene(s);

    }

    


}

void FailBoy::LockDelay()

{

    SimpleAudioEngine::sharedEngine()->playEffect("failDrop.mp3");


}

void FailBoy::ScreamDelay()

{

    SimpleAudioEngine::sharedEngine()->playEffect("failShout.mp3");


}

FailBoy::~FailBoy()

{

    this->removeAllChildren();

    this->removeFromParent();

}




 

#ifndef __HardGame__StarAnimate__

#define __HardGame__StarAnimate__


#include <iostream>

#include "cocos2d.h"



using namespace cocos2d;

class StarAnimate : public cocos2d::CCSprite

{

public:

   static StarAnimate* create(CCTexture2D*texture);

   virtual bool init(CCTexture2D*texture);

   virtual ~StarAnimate();


};

#endif



#include "StarAnimate.h"

using namespace cocos2d;



StarAnimate* StarAnimate::create(CCTexture2D*texture)

{

    StarAnimate* star = new StarAnimate();

   if (star && star->init(texture))

    {

        star->autorelease();

       return star;

    }

    CC_SAFE_DELETE(star);

    return NULL;

};


bool StarAnimate::init(CCTexture2D*texture)

{

    

   if ( !CCSprite::initWithTexture(texture) )

    {

        return false;

    }

        

   CCAnimation* animation = CCAnimation::create();


   float eachwidth = texture->getContentSize().width/3;//每个切片宽

   for (int i = 0; i<3; i++)

    {

        animation->addSpriteFrameWithTexture(texture,CCRectMake(i*eachwidth, 0, eachwidth, this->getContentSize().height));

    }

    animation->setDelayPerUnit(0.08f);//必须设置否则不会动态播放

    animation->setRestoreOriginalFrame(true);//是否回到第一帧

    animation->setLoops(-1);//重复次数(-1无限循环)

   CCFiniteTimeAction* animate = CCAnimate::create(animation);

    //this->setPosition(ccp(size.width/2, size.height/2));

   this->runAction(animate);


       

    return true;

}

StarAnimate::~StarAnimate()

{

    this->removeAllChildren();

    this->removeFromParent();

}


 

 

 

#ifndef __HardestGameEver__rank__

#define __HardestGameEver__rank__

#include "cocos2d.h"

USING_NS_CC;

#include <iostream>

class Rank:public CCLayer

{

public:

    virtual bool init();

    static CCScene* scene();

    void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);

    virtual void ccTouchesMoved(CCSet *pTouches, CCEvent*pEvent);

    void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);

    ~Rank();

    virtual void keyBackClicked();

    CREATE_FUNC(Rank);

private:

    void back();

    void play(CCObject*Psender);

    void addsprite();

    void setsprite(CCSprite*sp1,CCSprite*sp2,int tag);

    int key;

   CCNode * node;

   CCSprite*sprite1;

   CCSprite*sprite2;

   CCSprite*sprite3;

   CCSprite*sprite4;

   CCSprite*sprite5;

   CCSprite*sprite6;


CCPoint startPoint;


};


#endif 



#include "rank.h"

#include "GameBegain.h"

#include "SimpleAudioEngine.h"

#include "Loadingscene.h"

bool Rank::init()

{

    CCSize size = CCDirector::sharedDirector()->getWinSize();

    if (!CCLayer::init())

    {

        return false;

    }

   

    key = 0;

     this->setTouchEnabled(true);

    this->setKeypadEnabled(true);

    //添加背景图片

    CCSprite* backround = CCSprite::create("FBrank_bg-iphone21.jpg");

    this->addChild(backround,0);

    backround->setPosition(ccp(size.width*0.5, size.height*0.5));

    //添加头

    CCSprite* title = CCSprite::create("FBrank_bg-iphone24.png");

    this->addChild(title,2);

    title->setPosition(ccp(size.width*0.5, size.height-title->getContentSize().height*0.4+2));

    //添加menu

    

    CCMenuItemImage * back =CCMenuItemImage::create("ranking_button016-iphone4.png","ranking_button016-iphone4.png"thismenu_selector(Rank::back));

    back->setPosition(ccp(back->getContentSize().width*0.75, size.height-back->getContentSize().height*0.6));

    CCMenu * menu = CCMenu::create(back,NULL);

    this->addChild(menu,2);

    menu->setPosition(CCPointZero);

    

    

    node = CCNode::create();

    this->addChild(node,1);

    

    this->addsprite();


    

        

    return true;

}

CCScene*Rank::scene()

{

    CCScene* scene = CCScene::create();

    Rank*layer = Rank::create();

    scene->addChild(layer);

    return scene;

}

void Rank::back()

{

    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("gen_click.mp3");

    CCDirector::sharedDirector()->replaceScene(GameBegain::scene());

}

void Rank::play(CCObject*Psender)

{

    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("gen_click.mp3");

    CCSprite * s = (CCSprite*)Psender;

    if (s->getPositionY() == sprite1->getPositionY())

    {

        CCDirector::sharedDirector()->replaceScene(Loadingscene::creat(TargetSceneGame2Scene1));

    }

    else if(s->getPositionY()==sprite2->getPositionY())

    {

        CCDirector::sharedDirector()->replaceScene(Loadingscene::creat(TargetSceneInstructionScene,2));

    }

    

    

    

}

Rank::~Rank()

{

    this->removeAllChildren();

}

void Rank::addsprite()

{

    //添加stageplay

    CCArray * array = CCArray::create();

    array->retain();

    sprite1 = CCSprite::create("G1.png");

    sprite2 = CCSprite::create("G2.png");

    sprite3 = CCSprite::create("G3.png");

    sprite4 = CCSprite::create("G4.png");

    sprite5 = CCSprite::create("G5.png");

    sprite6 = CCSprite::create("G6.png");

    array->addObject(sprite1);

    array->addObject(sprite2);

    array->addObject(sprite3);

    array->addObject(sprite4);

    array->addObject(sprite5);

    array->addObject(sprite6);

    

    

    

    CCSprite*n1 = CCSprite::create("N1.png");

    CCSprite*n2 = CCSprite::create("N2.png");

    CCSprite*n3 = CCSprite::create("N3.png");

    CCSprite*n4 = CCSprite::create("N4.png");

    CCSprite*n5 = CCSprite::create("N5.png");

    CCSprite*n6 = CCSprite::create("N6.png");

    array->addObject(n1);

    array->addObject(n2);

    array->addObject(n3);

    array->addObject(n4);

    array->addObject(n5);

    array->addObject(n6);


    

   

    for (int i=0; i<6; i++)

    {

        

        this->setsprite((CCSprite*)array->objectAtIndex(i),(CCSprite*)array->objectAtIndex(i+6),i+1);

        node->addChild((CCSprite*)array->objectAtIndex(i),6-i);

        

    }

    

    

    CCSprite*lock3 = CCSprite::create("Lock2.png");

    lock3->setScale(0.5);

    sprite3->addChild(lock3,5);

    lock3->setPosition(ccp(sprite3->getContentSize().width*0.9sprite3->getContentSize().height*0.3));

    

    CCSprite*lock4 = CCSprite::create("Lock2.png");

    lock4->setScale(0.5);

    sprite4->addChild(lock4,5);

    lock4->setPosition(ccp(sprite4->getContentSize().width*0.9sprite4->getContentSize().height*0.3));

    

    CCSprite*lock5 = CCSprite::create("Lock2.png");

    lock5->setScale(0.5);

    sprite5->addChild(lock5,5);

    lock5->setPosition(ccp(sprite5->getContentSize().width*0.9sprite5->getContentSize().height*0.3));

    

    CCSprite*lock6 = CCSprite::create("Lock2.png");

    lock6->setScale(0.5);

    sprite6->addChild(lock6,5);

    lock6->setPosition(ccp(sprite6->getContentSize().width*0.9sprite6->getContentSize().height*0.3));

    


    

    array->release();

    

    

    


}



void Rank::setsprite(CCSprite *sp1, CCSprite *sp2,int tag)

{

    CCSize size = CCDirector::sharedDirector()->getWinSize();

    sp1->setPosition(ccp(sp1->getContentSize().width*0.6, size.height-sp1->getContentSize().height*tag));

    sp1->addChild(sp2);

    sp2->setPosition(ccp(0, sp1->getContentSize().height-sp2->getContentSize().height*0.5));

    //

    CCMenuItemImage * s = CCMenuItemImage::create("FBrank-iphone4.png""FBrank-iphone4.png"thismenu_selector(Rank::play));

    s->setPosition(ccp(size.width-s->getContentSize().width, sp1->getPositionY()));

    //

    CCSprite* select = CCSprite::create("Game_select1.png");

    select->setPosition(ccp(size.width-s->getContentSize().width-80, sp1->getPositionY()));

    select->setScale(0.7);

    

    CCMenu * m = CCMenu::create(s,NULL);

    node->addChild(m);

    node->addChild(select);

    m->setPosition(CCPointZero);

    

    

}

void Rank::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)

{

    CCTouch * touch = (CCTouch *)pTouches->anyObject();

    startPoint = touch->getLocation();

    

}


void Rank::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)

{

    CCMoveTo * action = CCMoveTo::create(0.5fccp(0, -39));

    CCMoveTo * action1 = CCMoveTo::create(0.3fccp(0155));

        if (node->getPositionY()<-40)

    {

        if (node->numberOfRunningActions()==0)

        {

            node->runAction(action);

        }


    }

    else if(node->getPositionY()>160)

    {

        if (node->numberOfRunningActions()==0)

        {

            node->runAction(action1);

        }


    }

       

    startPoint = CCPointZero;

}


void Rank::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)

{

    CCTouch * touch = (CCTouch *)pTouches->anyObject();

    CCPoint location = touch->getLocation();

    CCPoint lo = ccpSub(location, startPoint);

    


    if (node->numberOfRunningActions()==0)

    {

         node->setPositionY(node->getPositionY()+lo.y);

    }

    startPoint = location;

}

void Rank::keyBackClicked()

{

    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("ComboMax.mp3");

    CCDirector::sharedDirector()->replaceScene(GameBegain::scene());

}


 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值