loading...
Cover image for How do I add the Star Wars intro to my iOS and Android mobile apps?

How do I add the Star Wars intro to my iOS and Android mobile apps?

brentonhouse profile image Brenton House ・3 min read

Ask-a-Geek: Answers to Frequently asked API and Mobile Questions (6 Part Series)

1) How do I add a custom font to my mobile app for iOS and Android? [SOLVED] 2) What are the best practices for architecting API authentication? 3 ... 4 3) API-First, Mobile-First, Design-First... How do I know where to start?? 4) How do I take a screenshot inside mobile app for iOS and Android? 5) How can my Titanium iOS app detect that a screenshot has been taken? 6) How do I add the Star Wars intro to my iOS and Android mobile apps?

Dear Geek,

I really want to try to add some 3d animations to my iOS and Android mobile app built with Titanium SDK. Specifically, I am trying to recreate the Star Wars intro with the scrolling text for May the 4th. I need it to work on both iOS and Android so any guidance you can give me would be very helpful!
 

  —   TITANIUM PADAWAN

Dear Padawan,

Do or do not. There is no try! 😃🤓

Titanium Mobile SDK supports all sorts of animations and since today is May the 4th, I will do you one better and not only show you how to do the animations BUT ALSO provide you with the code you need to recreate the Star Wars intro in Titanium Mobile for BOTH iOS and Android!

TL;DR

If you are in a hurry, you can jump to the solution where I provide the source code for a working Titanium app for both iOS and Android, but I encourage you to look at some of the explanations below to help understand what the code is doing.

Check out a demo video of the completed Titanium app with the Star Wars intro!

Taking a look at the code...

Understanding Animations

There are couple things to understand about animations and the differences in the underlying platforms (iOS and Android). iOS supports 3D Matrix type animations whereas Android only supports 2D Matrix animations. That doesn't mean that we can't do what you are looking for. It just means we need to use different functions for each. Here are some of the most common classes/properties used with animating a view.

  • Titanium.UI.Matrix3D - Apply a 3D Matrix to a view in iOS
  • Titanium.UI.Matrix2D - Apply a 2D Matrix to a view in iOS and Android
  • Ti.UI.Animation - Apply one or more animations to any view in iOS and Android.
  • rotationX - Property available on every Android view that allows rotation around x-axis
  • rotationY - Property available on every Android view that allows rotation around y-axis

Star Wars: The Code

As you know, Titanium Mobile apps for iOS and Android are cross-platform native which means they are written in JavaScript and XML and then a native app (in Objective-C/Swift or Java) is created at compile-time. To accomplish the task of creating the Star Wars Intro, We only need one view and controller.

There are 3 basic views that we are creating:

  • The blue text that starts with "A long time ago in a galaxy..."
  • The title (May the 4th 2020 -- for this app)
  • The yellow text that scrolls up and back

Everything else is pretty much just the standard, default app that you get when you create a new cross-platform native mobile app using Titanium!

Star Wars: The View

The view starwars.xml will be used to define the views that we will need to create for this. Notice that some of the views are hidden (visibility = false) so that they can be shown later in the sequence.

Star Wars: The Controller

The controller starwars.js is a JavaScript file where we define and execute the animations. They are broken into 3 different functions, with each one kicking off the next after they are complete.

Solution

You can find the code for a complete working mobile application for iOS and Android that includes the Star Wars intro here! Enjoy and May the 4th be with you always!!

GitHub logo brentonhouse / may-the-4th

May the 4th be with you always! - Star Wars intro for iOS and Android mobile app

May the 4th be with you!

How do I add the Star Wars intro to my iOS and Android mobile apps?

Dear Geek,

I really want to try to add some 3D animations to my iOS and Android mobile app built with Titanium SDK. Specifically, I am trying to recreate the Star Wars intro with the scrolling text for May the 4th. I need it to work on both iOS and Android so any guidance you can give me would be very helpful!

  —   TITANIUM PADAWAN

Blog post

Read the accompanying blog post that talks about using Titanium to build a Star Wars intro in a cross-platform native mobile app for iOS and Android.

https://devblog.axway.com/

Demo video of mobile app with Star Wars intro

Click here to see video of mobile app in action!

Solution

You can find the code for a complete working mobile application for iOS and Android that includes the Star Wars intro here! Enjoy and May…

https://github.com/brentonhouse/may-the-4th

About Brenton House
With 25 years of experience in the development world, Brenton House leads Developer Relations for Axway's API and mobile products, He has worked closely with many clients across various industries including broadcasting, advertising, retail, financial services, transportation, publishing, supply chain, and non-profits. Brenton's passion for everything API and mobile combined with his strategy and design experience, has enabled him to help developers create captivating products that inspire and delight audiences.

Ask-a-Geek questions are answered by Brenton House, an API and Mobile geek who has been doing dev work for 25+ years.

Ask-a-Geek: Answers to Frequently asked API and Mobile Questions (6 Part Series)

1) How do I add a custom font to my mobile app for iOS and Android? [SOLVED] 2) What are the best practices for architecting API authentication? 3 ... 4 3) API-First, Mobile-First, Design-First... How do I know where to start?? 4) How do I take a screenshot inside mobile app for iOS and Android? 5) How can my Titanium iOS app detect that a screenshot has been taken? 6) How do I add the Star Wars intro to my iOS and Android mobile apps?

Posted on May 4 by:

brentonhouse profile

Brenton House

@brentonhouse

API and Mobile Strategist with 25+ years in dev community. Head #DevRel Geek at Axway and host of Breaking the Build YouTube series.

Discussion

markdown guide