• CCMotionStreak(一)


    void MotionStreakTest1::onEnter()
    {
        MotionStreakTest::onEnter();
    
        CCSize s = CCDirector::sharedDirector()->getWinSize();
      
        // the root object just rotates around
        m_root = CCSprite::create(s_pPathR1);
        addChild(m_root, 1);
        m_root->setPosition(ccp(s.width/2, s.height/2));
      
        // the target object is offset from root, and the streak is moved to follow it
        m_target = CCSprite::create(s_pPathR1);
        m_root->addChild(m_target);
        m_target->setPosition(ccp(s.width/4, 0));
    
        // create the streak object and add it to the scene
        streak = CCMotionStreak::create(2, 3, 32, ccGREEN, s_streak);
        addChild(streak);
        // schedule an update on each frame so we can syncronize the streak with the target
        schedule(schedule_selector(MotionStreakTest1::onUpdate));
      
        CCActionInterval* a1 = CCRotateBy::create(2, 360);
    
        CCAction* action1 = CCRepeatForever::create(a1);
        CCActionInterval* motion = CCMoveBy::create(2, ccp(100,0) );
        m_root->runAction( CCRepeatForever::create((CCActionInterval*)(CCSequence::create(motion, motion->reverse(), NULL)) ) );
        m_root->runAction( action1 );
    //最后的颜色会跟背景色一致,这样就达到逐渐消失的效果
        CCActionInterval *colorAction = CCRepeatForever::create((CCActionInterval *)CCSequence::create(
            CCTintTo::create(0.2f, 255, 0, 0),
            CCTintTo::create(0.2f, 0, 255, 0),
            CCTintTo::create(0.2f, 0, 0, 255),
            CCTintTo::create(0.2f, 0, 255, 255),
            CCTintTo::create(0.2f, 255, 255, 0),
            CCTintTo::create(0.2f, 255, 0, 255),
            CCTintTo::create(0.2f, 255, 255, 255),
            NULL));
    
        streak->runAction(colorAction);
    }
    
    void MotionStreakTest1::onUpdate(float delta)
    {
    //先获取精灵m_target左上角的坐标,然后赋值给streak,m_target的坐标一直在变化
        streak->setPosition( m_target->convertToWorldSpace(CCPointZero) );
    }

  • 相关阅读:
    python 序列应用
    跨浏览器本地存储框架(store.js/USTORE.js/Box.js)
    【设计开发命名必备】英语单词缩写规则
    Web服务器性能估算
    Spring整合FreeMarker本地化动态设置
    mybatis注解详解
    两种Freemarker模板路径设置方法
    Drools5集成Spring3
    Oracle 时间戳生成语句(秒级+毫秒级)
    Drools动态加载规则文件
  • 原文地址:https://www.cnblogs.com/newlist/p/3213598.html
Copyright © 2020-2023  润新知