NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

SOLVED: Opening Credits Crawl (Like Star Wars)

Forums > Swift

I want to present a narrative to my user when first entering my game. They have the option to skip and move on to game play, but would envision something like the opening scene to every Star Wars movie with text starting at the bottom, and moving away into infinity. For now, I'd be happy w/ something that will just automatically scroll up the screen until finished.

I've thought of using an SKLabelNode with a numberOfLines set to something way high, formatting my text w/ "\n" line breaks then doing a move action to slowly "crawl" it up the screen but wondering if anyone has a better solution to something like this.

Thanks...and loving the forum Paul...checking it multiple times a day.

   

If SwiftUI is an option, you could try this:

How to Create Star Wars Animated Text Using SwiftUI

2      

You'd probably use a scroll view for that.

See if this link helps: https://stackoverflow.com/questions/2234875/programmatically-scroll-a-uiscrollview

1      

Ended up with this, which works great:

  • Create a multiline SKLabelNode with alpha set to 0.0
  • Add my text lines which are created by slicing up a single long String into an array of shorter Strings that are created dynamically based on screen width and font size
  • Placed the SKLabelNode just off the bottom of the screen
  • Run SKAction.sequence that does:
    • Drives movement up the screen
    • When it moves off the top of the scene, fade out and .removeFromParent()
  • If the user dosn't want to watch the entire scroll, after a short delay, a "button" (actionable custom BorderedLabelNode) is added to "Skip Narrative" and move on to the next behavior.

1      

Hacking with Swift is sponsored by Paw

SPONSORED Use Paw to build, test and describe web APIs. Paw has a lightning fast native macOS interface to compose requests, collaborate in real-time on API specs, and generate client code for your applications. You can import and export API definitions.

Discover Paw for Mac

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

Not logged in

Log in
 

Link copied to your pasteboard.