2017年5月14日日曜日

cocos2d-x drawnodeのアニメーション

正しいかどうかはわからないがメモ

updateスケジュールを呼び出せるようにする

void update(float frame){

    draw->clear();

    std::vector<Vec2>poly;

    radius++;

    constexpr float pointN = 10;

    constexpr float Pi2 = M_PI * 2 / pointN;

    for(int i = 0; i < pointN; i++){

        poly.push_back(Vec2( pos.x + ( cos( Pi2*i ) * radius),
                             pox.y+ ( sin( Pi2*i ) * radius)  ));

    }

    draw->drawPolygon(&poly[0], pointN, Color4F(1.f, 1.f, 1.f, 1.f), 0, Color4F::BLACK);

}

上の例だと毎フレームごとに円が大きくなる
移動はrunactionメソッドでできる
以上