Calling SKAction.follow(..) causes my SKSpriteNode to rotate 90 degrees CW and not stay horizontal as it follows my UIBezierPath?
I have this code (within my GameViewController
Class) which implements the following of a SKSpriteNode along a UIBezierPath
.
=====
Please note that a brilliant contributor solved the above challenge by creating a new Class
, e.g., class NewClass: NSObject. Nevertheless, I need the solution to appear in an extension
of my GameViewController
=====
func createTrainPath() {
trackRect = CGRect(x: tracksPosX - tracksWidth/2,
y: tracksPosY,
width: tracksWidth,
height: tracksHeight)
trainPath = UIBezierPath(ovalIn: trackRect)
} // createTrainPath
func startFollowTrainPath() {
var trainAction = SKAction.follow(
trainPath.cgPath,
asOffset: false,
orientToPath: true,
speed: theSpeed)
trainAction = SKAction.repeatForever(trainAction)
myTrain.run(trainAction, withKey: runTrainKey)
} // startFollowTrainPath
func stopFollowTrainPath() {
guard myTrain == nil else {
myTrain.removeAction(forKey: runTrainKey)
savedTrainPosition = getPositionFor(myTrain, orPath: trainPath)
return
}
} // stopFollowTrainPath
-- SOLVED --
The MAGIC centers on
(a) initializing the animated GIFs for display on the “top” every time there is a newGame()
(b) re-creating the animated GIFs with GameScene’s update(..) method.
I owe my "sanity" to both @DonMag on StackOverflow and to John at Apple DTS. Two huge Atta-Boys to these blooming geniuses.
-- end SOLVED --