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"); } }

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...