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");
}
}
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");
}
}
相关文章推荐
- 2016 CocosPods安装教程
- cocos2d 了解
- cocos 对应版本和 对应ndk 参考网址
- cocos2d-x 生成pro.android 时找不到 ndk, prase NDK version RELEASE.TXT faild
- cocos2D-X源码分析之从cocos2D-X学习OpenGL(7)----GLSL
- Cocos2dx v3.10 pageview addeventlistener不起作用
- Cocos2d-vs避免过长编译的小技巧
- Cocos2d-x 多分辨率适配完全解析
- JNI针对于cocos2dx
- LuaJavaBridge - Lua 与 Java 互操作的简单解决方案(对于QUICK-COCOS开发者是很好的文章)
- UIKit和Cocos2d-x的整合使用;设置CCEAGLView背景为透明,来显示背后的UIView; 以及整合中遇到的问题的解决方案
- 用Android studio创建Cocos2d-x 3.X项目
- cocos2d-x 开启多触点
- cocos2d-x 之 CCPhysicsSprite 基于物理引擎的Sprite
- 关于cocos2dx客户端程序的自动更新解决方案
- 通过 Bitmap Font Generator 生成 fnt 与 png 文件供 cocos2d-x 中 LabelBMFont 使用达到以图片表现数字
- cocos2dx::ui::Text 显示问题
- OS X环境下如何搭建编译Cocos2D-X v3.x的Android Studio工程
- cocos2dx的命令行编译出现 error: undefined reference to ‘xxx’
- cocos2dx内存管理