cocos2dX-地图滚动

cocos2dX-地图滚动,第1张

概述bool ScrollMap::init(){if (!CCLayer::init()){return false;}do {CCSprite * map1 = CCSprite::create("Images/gir/BG1.png");CCSprite * map2 = CCSprite::create("Images/gir/BG1.png");map1->set
bool ScrollMap::init(){if (!cclayer::init()){return false;}do {CCSprite * map1 = CCSprite::create("Images/gir/BG1.png");CCSprite * map2 = CCSprite::create("Images/gir/BG1.png");map1->setTextureRect(CCRectMake(0,winSize.wIDth,winSize.height));map2->setTextureRect(CCRectMake(0,winSize.height));addChild(map1,MAP_1_Tag);addChild(map2,MAP_2_Tag);CCSize mapSize = map1->getContentSize();map1->setposition(ccp(0,0));map2->setposition(ccp(map1->getpositionX()+mapSize.wIDth,0));//map1的宽加map2的宽;map1->setAnchorPoint(ccp(0,0));map2->setAnchorPoint(ccp(0,0));//cclog("%f",map1->getContentSize().wIDth+origin.x);scheduleUpdate();} while (0);return true;}voID ScrollMap::update(float dt){CCSprite * temp1 = (CCSprite *)getChildByTag(MAP_1_Tag);CCSprite * temp2 = (CCSprite *)getChildByTag(MAP_2_Tag);temp1->setpositionX(temp1->getpositionX() - 5);temp2->setpositionX(temp2->getpositionX() - 5);if (temp2->getpositionX()<=0){temp1->setpositionX(temp2->getpositionX() + temp1->getContentSize().wIDth);}if (temp1->getpositionX()<= 0){temp2->setpositionX(temp1->getpositionX() + temp2->getContentSize().wIDth);}}voID ScrollMap::onExit(){unscheduleUpdate();cclayer::onExit();}
总结

以上是内存溢出为你收集整理的cocos2dX-地图滚动全部内容,希望文章能够帮你解决cocos2dX-地图滚动所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1020086.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存