Skip to main content

Day 87

About 3 minSwiftcrashcoursepaul-hudsonswifthacking-with-swiftxcodeappstore

Day 87 ๊ด€๋ จ


100 Days of Swift - Day 87

Project 26, part three

Project 26, part three

Seth Godin โ€“ author and marketing genius โ€“ once said โ€œsurprise and delight and connection are remarkable.โ€ We already looked at connection way back in project 10, Names to Faces, where importing user photos transformed our collection view into something far more personal โ€“ and thus far more important to users.

The accelerometer is an almost invisibly small component in iOS devices, but I hope this project has shown you that it brings a fresh dose of delight to our apps โ€“ and thatโ€™s even after youโ€™ve learned about many of the other frameworks iOS makes available to us.

As for โ€œsurpriseโ€, this is somewhere we need to be a little more careful. You see, users trust us with their data: our code is running on their phone, which is packed with their lifetime of photos, emails, chats, and more โ€“ itโ€™s a really personal device. If your app does something unexpected โ€“ if it behaves in a way they werenโ€™t expecting โ€“ itโ€™s easy to lose some trust, and once that trust is gone itโ€™s really hard to win back.

However, small amounts of surprise in safe places releases a little dopamine rush, making users feel good about our app. iOS is filled with tiny things like this: the way the flashlight button on the home screen grows with pressure then clicks with a physical bump, the smooth zoom animations seen in the App Store, or even the page curl reading effect in Apple Books. None of those risk user data or make the app feel uncertain, they are just tiny touches that feel great every time you interact with them.

Core Motion opens up a whole area of delight for us, but make sure you use it judiciously: if everything moves your users will feel queasy, but if you add a tiny touch here and there itโ€™s just one more thing to help bring your app to life.

Today you should work through the wrap up chapter for project 26, complete its review, then work through all three of its challenges.

Wrap up

Wrap up
100 Days of Swift - Day 87 - Wrap up

Wrap up

There's something wonderfully tactile about using the accelerometer to affect gravity in a game, because it feels incredibly realistic even though we're not using particularly good graphics.

SpriteKit is of course doing most of the hard work of collision detection, and Core Motion takes away all the complexity of working with accelerometers, so again it's our job to sew the components together to make something bigger than the sum of its parts.

Review what you learned

Anyone can sit through a tutorial, but it takes actual work to remember what was taught. Itโ€™s my job to make sure you take as much from these tutorials as possible, so Iโ€™ve prepared a short review to help you check your learning.

Click here to review what you learned in project 26.open in new window

Challenge

One of the best ways to learn is to write your own code as often as possible, so here are three ways you should try your new knowledge to make sure you fully understand whatโ€™s going on:

  1. Rewrite the loadLevel() method so that it's made up of multiple smaller methods. This will make your code easier to read and easier to maintain, or at least it should do if you do a good job!
  2. When the player finally makes it to the finish marker, nothing happens. What should happen? Well, that's down to you now. You could easily design several new levels and have them progress through.
  3. Add a new block type, such as a teleport that moves the player from one teleport point to the other. Add a new letter type in loadLevel(), add another collision type to our enum, then see what you can do.

Thatโ€™s another fun game complete, and one with lots of expansion possibilities โ€“ make sure you share your progress online!


์ด์ฐฌํฌ (MarkiiimarK)
Never Stop Learning.