核心代码如下:
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坐标小于一定阀值时,就让它回到刚开始的地方。与此同时,在它的上边拼接的那一张一直随第一张向下滚动,这样就无缝隙了。
本篇文章仅供参考。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。