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 );
  • 相关阅读:
    [编程题]多多的数字组合
    mac传输文件到服务器
    git 清除缓存、查看add内容
    go build
    vim编辑器
    Git: clone指定分支
    查看端口占用以及kill
    curl小记录
    Python3.9 malloc error: can’t allocate region
    设计模式-策略模式
  • 原文地址:https://www.cnblogs.com/newlist/p/3563893.html
Copyright © 2011-2022 走看看