SKAction按顺时针方向跟随Circle CGPathRef [英] SKAction to follow Circle CGPathRef in clockwise direction
本文介绍了SKAction按顺时针方向跟随Circle CGPathRef的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的SKSpriteNode沿逆时针方向跟随此路径,如何使其沿顺时针方向的路径移动?
My SKSpriteNode follows this path in a counterclockwise direction, how do i make it so it follows the path in a clockwise direction?
提前致谢!
CGPathRef circle = CGPathCreateWithEllipseInRect(CGRectMake(0,0,50,50), NULL);
SKAction *followTrack = [SKAction followPath:circle asOffset:YES orientToPath:YES duration:5.0];
SKAction *forever = [SKAction repeatActionForever:followTrack];
[player2 runAction:forever];
推荐答案
而不是 CGPathCreateWithEllipseInRect()
,使用 CGPathCreateMutable()
和 CGPathAddArc()
创建圆路径并使用顺时针
参数控制
方向。
Instead of CGPathCreateWithEllipseInRect()
, use CGPathCreateMutable()
and CGPathAddArc()
to create the circle path and use the clockwise
parameter to control
the direction.
未经测试的代码:
CGMutablePathRef circle = CGPathCreateMutable();
CGPathAddArc(circle, NULL, 25, 25, 25, 0, 2*M_PI, true);
CGPathCloseSubpath(circle);
这篇关于SKAction按顺时针方向跟随Circle CGPathRef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文