寒風的Cocos2d之旅之如何实现屏幕滚动
2015-09-16 21:44
537 查看
核心代码如下:
大致思路如下:
实现滚屏是让两幅图片拼接在一起,一张往下一直滚动,当它的Y坐标小于一定阀值时,就让它回到刚开始的地方。与此同时,在它的上边拼接的那一张一直随第一张向下滚动,这样就无缝隙了。
本篇文章仅供参考。
auto sp1=new Sprite("文件路径"); sp1->setAnchorpoint(Vec2::ZERO); sp1->setPosition(0,0); sp1->setTag(101); this->addChild(sp1); auto sp2=new Sprite("文件路径"); sp2->setAnchorpoint(Vec2::ZERO); sp2->setTag(102); sp2->setPosition(0,480); this->addChild(sp2);</span>
this->ScheduleUpDate();</span>
this->schedule(schedule_selecter(类名::gunping),0.1);
---------------------------------------- void 类名::gunping(float t){ this->getChildByTag(101)->setPositionY(this->getChildByTag(101)->getPositionY()-1); if(this->getChildByTag(101)->getPositionY<-480){ this->getChildByTag(101)->setPositionY(0); } this->getChildByTag(102)->setPositionY( this->getChildByTag(101)->getPositionY()+480); }
大致思路如下:
实现滚屏是让两幅图片拼接在一起,一张往下一直滚动,当它的Y坐标小于一定阀值时,就让它回到刚开始的地方。与此同时,在它的上边拼接的那一张一直随第一张向下滚动,这样就无缝隙了。
本篇文章仅供参考。
相关文章推荐
- 关于cocos2d-js中使用 ClippingNode 以及 BlendFunc 来实现遮罩
- 火云开发课堂 - 《使用Cocos2d-x 开发3D游戏》系列 第十八节:环境映射
- cocos2dx3.2 Other Linker Flags 设置成 -ObjC 真机编译报错
- cocos2d-x 3.x游戏开发学习笔记(1)--mac下配置cocos2d-x 3.x开发环境
- CCSprite(2)(cocos2dx-2.2.5)
- COCOS2D 释放资源的最佳时机
- 第一篇
- cocos2dx3.1-lua移植android流程
- cocos2d-x中,多个精灵执行同样的动作
- cocos2d-lua 3.5 ios搭建步骤
- cocos2d-lua 3.5 android搭建步骤
- iOS cocos2d 学习第一章 cocos2d游戏引擎环境安装
- cocos2d-x 3.x C++和Lua通信方式:Lua堆栈正数索引和负数索引的关系和用法
- Undefined symbols for architecture i386
- cocos2d-x-3.1 Text Labels(官方正式译文)
- 火云开发课堂 - 《使用Cocos2d-x 开发3D游戏》系列 第十七节:地表的实现
- Cocos2d-x开发中Ref内存管理
- cocos2d-lua 3.5 android搭建常见错误
- [Cocos2d-html5] 使用Ant一步一步压缩混淆Cocos2d-html5游戏
- 《Cocos2d-x实战(卷Ⅰ):C++开发》目录 (仅供参考)