您的位置:首页 > 移动开发 > Cocos引擎

cocos2d DrawNode图形渐变

2016-06-07 19:35 661 查看
//点变线

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

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: