cocos 2 d-x線引き

3727 ワード

class HelloWorld:public cocococos 2 d::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);
}

 
そのまま運転すればいいです
補足: