TextScroll: Week 3, June 24 – Michelle

This morning was spent trying to refine the reset button and display the acceleration stat on the screen. The reset button only slides the text back to its starting position if the iPad is perfectly level, otherwise it jerks back a few steps but fails to fully reset. I tried temporarily freezing the scrolling label while the user was prompted to reset or cancel, but what I tried would freeze the scrolling label entirely post-reset. Getting the acceleration to display and constantly update was also a challenge, since simply “speedLabel.text = scrollLabel.acceleration” wouldn’t update live. I got it to work after some complicated syntax I don’t wholly understand, but now that the acceleration value was displaying, the scroll label itself stopped working. Even though I have a general idea of what’s going on with ScrollingLabel, I couldn’t figure out how to get either of these two seemingly small adjustments to work since there was so much to keep track of.

Because of this, I started seriously considering an idea to entirely restructure ScrollingLabel that I had been turning around in my head for some time now. I was really excited by the buttery smooth physics in SpriteKit when working on the Hacking with Swift tutorials, and getting it all to work was really straightforward. However, these physics can only be accessed by image sprite nodes, so you can’t readily apply gravity and acceleration to plain text. What if I could create a custom class that inherited SKNode so that I could use SpriteKit physics on it? Essentially, it’d be text that also possessed Sprite Kit node physics and could move around as if it were a rolling ball. I figured that making a test app wouldn’t take long, so I gave it a shot. Although I didn’t end up doing class inheritance, what my test app has is an SKNode ball that has tilt physics all set up for it, and a text label that simply matches the x coordinates of the ball. The result is a super smooth tilt-to-scroll text label, all in very few lines of code (and readers will know nothing about the ball because it’ll be invisible 🙂 ). I think if I can remake TextScroll around this new scrolling system, expanding upon the label (such as adding the blur preview) will be easier than modifying the old, complicated SL. I hope I can run with this!

What I’d like to get working next Monday is:

  • Get min/max offset working in this new system. Currently I just have the ball stopping when it hits the corner of the screen (and it does a little neat bump animation when it hits a wall), so I need to figure out how to adjust these wall boundaries to the size of the length of text.
  • Get the text window over the line of text. I’m pretty sure toggling blur preview on/off is just a matter of setting the color of the overlay around the text to semitransparent/solid.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s