zoukankan      html  css  js  c++  java
  • 手指效果

    HelloWorld::HelloWorld()
    
    {
    
        smoke=CCParticleSmoke::create();
    
        sun=CCParticleSun::create();
    
     
    
    }
    
    HelloWorld::~HelloWorld()
    
    {
    
        smoke->setAutoRemoveOnFinish(true);
    
        sun->setAutoRemoveOnFinish(true);
    
    }
    
     
    
    CCScene* HelloWorld::scene()
    
    {
    
        // 'scene' is an autorelease object
    
        CCScene *scene = CCScene::create();
    
        
    
        // 'layer' is an autorelease object
    
        HelloWorld *layer = HelloWorld::create();
    
     
    
        // add layer as a child to scene
    
        scene->addChild(layer);
    
     
    
        // return the scene
    
        return scene;
    
    }
    
     
    
    boolHelloWorld::init()
    
    {
    
     
    
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,0,false);
    
        bool bRet = false;
    
        do
    
        {
    
            CC_BREAK_IF(! CCLayer::init());
    
            
    
            CCSprite* pSprite = CCSprite::create("background.png");
    
            CC_BREAK_IF(! pSprite);
    
            pSprite->setPosition(ccp(400, 240));
    
    this->addChild(pSprite, 0);
    
            
    
     
    
    sun->setTextureWithRect(CCTextureCache::sharedTextureCache()->addImage("fire.png"),CCRectMake(0,0,32,32));
    
    sun->setPosition(ccp(700,350));
    
    addChild(sun);
    
     
    
    smoke->setTextureWithRect(CCTextureCache::sharedTextureCache()->addImage("fire.png"),CCRectMake(0,0,32,32));
    
    smoke->setPosition(ccp(600,150));
    
    smoke->setLife(1);
    
    addChild(smoke);
    
    strike=CCMotionStreak::create(1.0,16, 16, ccWHITE, "sprite.png");
    
    addChild(strike,1);
    
    strike->setPosition(ccp(240,160));
    
     
    
            
    
            
    
            bRet = true;
    
        } while (0);
    
        
    
        return bRet;
    
    }
    
    bool HelloWorld::ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
    
    {
    
        x=pTouch->getLocation().x;
    
        y=pTouch->getLocation().y;
    
        CCLog("ccTouchBegan");
    
        strike->setPosition(pTouch->getLocation());
    
        returntrue;
    
    }
    
    void HelloWorld::ccTouchMoved(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
    
    {
    
        CCLog("ccTouchMoved");
    
        getLine(pTouch->getLocation());
    
        strike->setPosition(pTouch->getLocation());
    
    }
    
    void HelloWorld::ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
    
    {
    
        if(fabs(pTouch->getLocation().x-x)<20&&fabs(pTouch->getLocation().y-y)<20)
    
        {
    
            getBoom(pTouch->getLocation());
    
        }
    
        CCLog("ccTouchEnded");
    
    }
    
     
    
    voidHelloWorld::getLine(CCPoint pt)
    
    {
    
        cocos2d::CCParticleSystemQuad *mSystem=CCParticleSystemQuad::create("Particle.plist");
    
        mSystem->setTextureWithRect(CCTextureCache::sharedTextureCache()->addImage("Particle.png")
    
                                    ,CCRectMake(0,0,32,32));
    
        mSystem->setPosition(pt);
    
        mSystem->setDuration(0.3f);
    
        mSystem->setLife(0.5f);
    
        addChild(mSystem);
    
        mSystem->setAutoRemoveOnFinish(true);
    
    }
    
     
    
    voidHelloWorld::getBoom(CCPoint pt)
    
    {
    
        
    
        CCParticleSystemQuad*mSystem2 = CCParticleSystemQuad::create("Boom.plist");
    
        mSystem2->setTextureWithRect(CCTextureCache::sharedTextureCache()->addImage("fire.png")
    
                                     ,CCRectMake(0,0,32,32));
    
        mSystem2->setPosition(pt);
    
        mSystem2->setDuration(0.05f);
    
        addChild(mSystem2);
    
        mSystem2->setAutoRemoveOnFinish(true);
    
    }
  • 相关阅读:
    考研系列 HDU2241之早起看书 三分
    考研系列 HDU2242之空调教室 tarjan
    HDU5880 Family View ac自动机第二题
    HDU2222 Keywords Search ac自动机第一题
    hiho1514 偶像的条件 lower_bound
    HDU1800 hash+去前导0
    阿里云数据库自研产品亮相国际顶级会议ICDE 推动云原生数据库成为行业标准
    MaxCompute 图计算开发指南
    MaxCompute Mars开发指南
    基于MaxCompute的数仓数据质量管理
  • 原文地址:https://www.cnblogs.com/jiackyan/p/3037627.html
Copyright © 2011-2022 走看看