zoukankan      html  css  js  c++  java
  • cocos2d-x画线

    在class HelloWorld : public cocos2d::CCLayer中添加

    void draw();

    实现:

    void HelloWorld::draw()
    {
    
        CCSize s = CCDirector::sharedDirector()->getWinSize();
        CCPointArray *array = CCPointArray::create(20);
    
        array->addControlPoint(ccp(0, 0));
        array->addControlPoint(ccp(80, 80));
        array->addControlPoint(ccp(s.width - 80, 80));
        array->addControlPoint(ccp(s.width - 80, s.height - 80));
        array->addControlPoint(ccp(80, s.height - 80));
        array->addControlPoint(ccp(80, 80));
        array->addControlPoint(ccp(s.width / 2, s.height / 2));
    
    
        CCPointArray *array2 = CCPointArray::create(20);
    
        array2->addControlPoint(ccp(s.width / 2, 30));
        array2->addControlPoint(ccp(s.width  -80, 30));
        array2->addControlPoint(ccp(s.width - 80, s.height - 80));
        array2->addControlPoint(ccp(s.width / 2, s.height - 80));
        array2->addControlPoint(ccp(s.width / 2, 30));
                    //个人理解是初始化用来存放点的栈
        kmGLPushMatrix();
                    //定义栈的大小
        kmGLTranslatef(50, 50, 0);
                    //绘制曲线
        ccDrawCatmullRom(array, 50);
                    //绘制完后弹出所存放的点
        kmGLPopMatrix();
                    //由于上面只是弹出并不是释放,所以仍然可以通过点栈来绘制曲线
        ccDrawCatmullRom(array2,50);
    }

    然后直接运行就可以了

    补充:

  • 相关阅读:
    MVC ORM 架构
    Kubernetes 第八章 Pod 控制器
    Kubernetes 第七章 Configure Liveness and Readiness Probes
    Kubernetes 第六章 pod 资源对象
    Kubernetes 第五章 YAML
    Kubernetes 核心组件
    Kubernetes 架构原理
    Kubernetes 第四章 kubectl
    Kubernetes 第三章 kubeadm
    yum 配置及yum 源配置
  • 原文地址:https://www.cnblogs.com/newlist/p/3204212.html
Copyright © 2011-2022 走看看