CardinalSpline样条曲线(沿着正方形路线走)
CardinalSpline样条曲线(沿着正方形路线走)
1 ////////////// CardinalSpline 样条曲线 /////////////// 2 3 Sprite* sprite = Sprite::create("button.png"); 4 //sprite->setPosition(Vec2(visibleSize.width * 0.2, visibleSize.height * 0.5)); 5 this->addChild(sprite); 6 7 // 专门存放点的数组 8 PointArray *arr = PointArray::create(10); 9 arr->addControlPoint(Vec2(visibleSize.width * 0.2, visibleSize.height * 0.2)); 10 arr->addControlPoint(Vec2(visibleSize.width * 0.2, visibleSize.height * 0.8)); 11 arr->addControlPoint(Vec2(visibleSize.width * 0.8, visibleSize.height * 0.8)); 12 arr->addControlPoint(Vec2(visibleSize.width * 0.8, visibleSize.height * 0.2)); 13 arr->addControlPoint(Vec2(visibleSize.width * 0.2, visibleSize.height * 0.2)); 14 15 // 参数(时间,点数,(1代表是直线, >1或<1 都是曲线 )) 16 //ActionInterval * spline = CardinalSplineTo::create(5.0f, arr, 1); 17 //ActionInterval * spline = CardinalSplineTo::create(5.0f, arr, 0.3); 18 //ActionInterval * spline = CardinalSplineTo::create(5.0f, arr, 5); 19 20 //ActionInterval * spline = CardinalSplineBy::create(5.0f, arr, 1); 21 //ActionInterval * spline = CardinalSplineBy::create(5.0f, arr, 0.3); 22 ActionInterval * spline = CardinalSplineBy::create(5.0f, arr, 5); 23 24 25 sprite->runAction(spline); 26 27 ////////////// CardinalSpline 样条曲线 ///////////////