博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CCParallaxNode
阅读量:4460 次
发布时间:2019-06-08

本文共 1208 字,大约阅读时间需要 4 分钟。

// 创建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 );

 

转载于:https://www.cnblogs.com/newlist/p/3563893.html

你可能感兴趣的文章
nodejs 构建本地web测试服务器 以及 解决访问静态资源的问题!有完整源码!
查看>>
Android 勤用RXJava compose操作符消除重复代码
查看>>
BaseFragment
查看>>
QQ网站接入
查看>>
Android自定义控件 开源组件SlidingMenu的项目集成
查看>>
android中的textview显示汉字不能自动换行的一个解决办法
查看>>
Android sqlite日期存储
查看>>
简单实例一步一步帮你搞清楚MVC3中的路由以及区域
查看>>
如何在Eclipse配置Tomcat服务器
查看>>
HDU 1018 Big Number
查看>>
周记(2015-11-22 -- 2015-11-27)
查看>>
面试JS
查看>>
2014年最佳的10款 PHP 开发框架
查看>>
Bower快速学习
查看>>
Spring Cloud学习笔记-003
查看>>
JQuery语法总结和注意事项
查看>>
常见的时间复杂度
查看>>
8086CPU如何用内部16位的数据转换成20位的地址
查看>>
WCF 之UserName身份验证全记录(转)(一)
查看>>
转 linux screen 命令详解
查看>>