ios – 如何使用Sprite Kit减慢运行SKAction followPath的慢速运动效果的SKSpriteNode?

我基本上希望动作正在运行,然后在动作的中间创建一个慢动作效果,然后将其从慢动作中解脱出来.有没有人有什么好的反馈如何这样做?我已经考虑过手动创建操作并使用更新方法,但我觉得这可能是过度的.我希望得到一个更简单的解决方案.

一个想法是停止这个动作,然后在较慢的时间内重新开始,但是我不认为它会保持在相同的路径上,它可能看起来很奇怪.

这是我用来创建动作的代码.

CGMutablePathRef cgpath = CGPathCreateMutable();
CGPathMovetoPoint(cgpath,NULL,mysprite.position.x,mysprite.position.y);
CGPathAddCurvetoPoint(cgpath,cp1.x,cp1.y,cp2.x,cp2.y,e.x,e.y);
[mysprite runAction:[SKAction sequence:@[[SKAction followPath:cgpath asOffset:NO orientToPath:YES duration:3]]]];
CGPathRelease(cgpath);

解决方法

每个节点具有速度属性

A speed modifier applied to all actions executed by a node and its
descendants.

discussion
The default value is 1.0,which means that all actions run
at their normal speed. If you set a different speed,time appears to
run faster or slower for all actions executed on the node and its
descendants. For example,if you set a speed value of 2.0,actions run
twice as fast.

您可以将其设置为小于1的值,以使操作更慢.甚至可以动画速度逐渐减慢:

[mySprite runAction:[SKAction speedTo:0.5 duration:1.0]];

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...