Why does orient Path = true cause the sprite node to rotate CW when the path is horizontal?

48 Views Asked by At

Why does orient Path = true cause the sprite node to rotate CW when the path is horizontal?

== BEGIN Edit ==

(1) Someone suggested I need to create a Pivot Point. However, based on my research, a Pivot Point exists for a SCNode, not a SKSpriteNode.

(2) No luck even when I changed the anchorPoint to various x,y combinations. Problem did not go away no matter what combination I chose. It's currently set to 0.5,0.5. I am definitely ready to cry "Uncle" on this challenge.

(3) So, allow me to continue ...

== END Edit ==

Here's just one example of my challenge:

    let trainAction = SKAction.follow(
                                  trainPath.cgPath,
                                  asOffset: false,
                                  orientToPath: true,
                                  duration: 0.1)
    myTrain.run(trainAction.reversed())

I have myTrain.zRotation = 0.0

myTrain is a simple locomotive,trainPath = the railroad tracks

Docs state with orientToPath: true, that the Node will always orient itself such that it's facing the UIBezierPath.

To me, facing means that the wheels of the locomotive are facing the BezierPath (= trainPath)

Apparently I am wrong in this interpretation ... if so, what is the correct interpretation?

FYI, here is a snapshot of my initial placement of the locomotive on the tracks using .position:

enter image description here

... and here is what happens when I start moving the locomotive:

enter image description here

These snapshots indicate that facing means that the nose of the locomotive is facing the BezierPath (= trainPath).

If true, how do I eliminate that CW rotation?

I have even tried rotating myTrain CCW 90 degrees before the .follow = same exact result.

I have drawn what I am looking for - hopefully it helps to diagnose my problem:

enter image description here

0

There are 0 best solutions below