zoukankan      html  css  js  c++  java
  • CCParallaxNode

    // 创建cat精灵
        CCSprite* cat = CCSprite::create("Image\grossini.png");
        //change the transform anchor point to 0,0 (optional)
        cat->setAnchorPoint( ccp(0,0) );
        //创建 background 精灵最为背景
        CCSprite* background = CCSprite::create("Image\background.png");
        // scale the image (optional)
        background->setScale( 2.0f );
        // change the transform anchor point (optional)
        background->setAnchorPoint( ccp(0,0) );
    
        // 创建一个parallax节点用于储存各种精灵,然后移动parallax节点以展示“视差”效果
        CCParallaxNode* voidNode = CCParallaxNode::create();
        // background的移动速度为 0.4x, 0.5y
        voidNode->addChild(background, -1, ccp(0.4f,0.5f), CCPointZero);
        // cat的移动速度为 3.0x, 2.5y
        voidNode->addChild(cat, 1, ccp(3.0f,2.5f), ccp(200,800) );
        
        //移动 CCParallaxNode 产生视差效果
        CCActionInterval* goUp = CCMoveBy::create(4, ccp(0,-500) );
        CCActionInterval* goDown = goUp->reverse();
        CCActionInterval* go = CCMoveBy::create(8, ccp(-1000,0) );
        CCActionInterval* goBack = go->reverse();
        CCFiniteTimeAction* seq = CCSequence::create(goUp, go, goDown, goBack, NULL);
        voidNode->runAction( (CCRepeatForever::create((CCActionInterval*) seq) ));
        
        addChild( voidNode );
  • 相关阅读:
    C# Dictionary 字典
    int.Parse()与int.TryParse()
    jquery 随机数
    DateGradeView分页绑定
    使用tcpdump抓Android网络包
    Android快速开发框架——AndroidAnnotations(Code Diet)
    浅谈 android-query
    Android网络框架技术
    PHP: 深入了解一致性哈希
    png图片压缩优化
  • 原文地址:https://www.cnblogs.com/newlist/p/3563893.html
Copyright © 2011-2022 走看看