
老项目的渲染方式-draw函数中调用
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) gllinewidth(2.0f); //glEnable(GL_liNE_WIDTH);#else gllinewidth(2.0f); glEnable(GL_liNE_SMOOTH);#endif ccDrawcolor4F(1.0f,1.0f,0.5f); BattleTerrain *terrain = BattleScene::getCurrentScene()->getTerrain(); if(!terrain) return; for (int i = 0; i < terrain->getWIDth(); ++i) { GrIDposition down = GrIDposition(i,0); GrIDposition up = GrIDposition(i,BattleScene::getCurrentScene()->getTerrain()->getHeight()); CCPoint downPoint = ccp(GrIDUtil::sharedGrIDUtil().grIDEdgetoPix(down).x,GrIDUtil::sharedGrIDUtil().grIDEdgetoPix(down).y); CCPoint upPoint = ccp(GrIDUtil::sharedGrIDUtil().grIDEdgetoPix(up).x,GrIDUtil::sharedGrIDUtil().grIDEdgetoPix(up).y); ccDrawline(downPoint,upPoint); }
新项目的方式,重写新的draw函数,在onDraw中绘制
voID SceneLayer::draw(Renderer *renderer,const Mat4& transform,uint32_t flags){ _customCommand.init(_globalZOrder,transform,flags); _customCommand.func = CC_CALLBACK_0(SceneLayer::onDraw,this,flags); renderer->addCommand(&_customCommand);}
先将drawNode节点添加到父节点中
_drawNode = CCDrawNode::create();addChild(_drawNode);
_drawNode->clear();
_drawNode->clear(); for (int i = 0; i < terrain->getWIDth(); ++i) { GrIDposition down = GrIDposition(i,GrIDUtil::sharedGrIDUtil().grIDEdgetoPix(up).y); _drawNode->drawline(downPoint,upPoint,cccolor4F(1.0f,0.5f)); //ccDrawline(downPoint,upPoint); } 总结 以上是内存溢出为你收集整理的将旧项目基于cocos2dx 2.x的调试绘制转移到cocos2dx 3.x中全部内容,希望文章能够帮你解决将旧项目基于cocos2dx 2.x的调试绘制转移到cocos2dx 3.x中所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)