cocos2d DrawNode图形渐变

前端之家收集整理的这篇文章主要介绍了cocos2d DrawNode图形渐变前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

//点变线

void HelloWorld::dotChangeToLine(int curMenutag)

{
log("dotChangeToLine");

//是一条窄窄的矩形线
DrawNode* drawmove = static_cast<DrawNode*>(PointMoveBox->getChildByTag(SolidLineTag)); //two words len subline


drawhome->setVisible(false);


this->schedule(schedule_selector(HelloWorld::updateDotToTVLine),DOT_UPDATE_TIME);

}


void HelloWorld::updateDotToTVLine(float dt)
{
log("updateDotToTVLine 1234");

DrawNode* drawmove = static_cast<DrawNode*>(PointMoveBox->getChildByTag(SolidLineTag)); //two words len subline

//将原图形清掉
drawmove->clear();

//左边办越来越向左去
m_rectLeft = m_rectLeft - DOT_CHANGE_SPEED;

//右边界越来越向右去
m_rectRight = m_rectRight + DOT_CHANGE_SPEED;


Vec2 oriP = Vec2(m_rectLeft,POINT_MOVE_Five - POINT_MOVE_Three); // 80 - POINT_MOVE_FIVE
Vec2 endP = Vec2(m_rectRight,POINT_MOVE_Five + POINT_MOVE_Three);


Color4F lineColor = Color4F(Color3B(60,190,240)); //line color
drawmove->drawSolidRect(oriP,endP,lineColor); //绘制变大的矩形
int lineWidth = m_rectRight - m_rectLeft;

//如果宽度达到了标准,就停止渐变 if (lineWidth >= 2 * POINT_MOVE_Vec2x_Increment_Sixty) //when line width add to orign width,stop become width { this->unschedule(schedule_selector(HelloWorld::updateDotToTVLine)); //Node::unschedule("updateLineToDot"); log("unschedule updateDotToTVLine"); } }

原文链接:https://www.f2er.com/cocos2dx/339615.html

猜你在找的Cocos2d-x相关文章