Tin Cans 3: Get your game on a phone, get that phone to vibrate

I've gone with the simplest free route possible here. There are definitely "better" ways, but all involve learning a lot of code, and can be quite expensive, and that strikes me as being against the point of using twine. Having said that, the next steps can be pretty frustrating if something goes wrong. Don't panic, just Google the error message, or get in touch with me on Twitter at@gritfish. I'll try and update this with any troubleshooting that comes up.

**UPDATE**

There's one possible issue with Twine as a mobile app that I didn't see coming: If the app is in the background for more than a few minutes, Android will remove it from memory, restarting it when the app is opened again. This is something I'm still trying to find a workaround for.

5) APPCELERATOR TITANIUM

Download Appcelerator Titanium here: https://my.appcelerator.com/auth/signup

Download Java JDK 1.6:http://www.oracle.com/technetwork/java/javase/downloads/jdk6downloads-1902814.html

Creating the titanium wrapper:

  • Create a new Project for your game
  • Select "Default Project" as the project type
  • Give your project a name (this will show under the icon in the apps menu) and an ID (the traditional way to name this is your website url in reverse, followed by the project name eg if my game was called town, i'd put "net.gritfish.town")
  • Uncheck the "Automatically cloud-enable this application" because we aren't using that
  • Delete the contents of the "Resources" folder
  • Download the Zip here
  • Extract all the files into the "Resources" folder
  • Save your twine html file in the HTML folder as "index.html" (publishing with the "tincansmobile" story format)
  • Copy all the files from the "tincansmobile" format directory (except the "header.html" file) into the HTML folder

6) EDIT THE APP.XML FILE (to get rid of the default nav bar, which we don't need)

Double-click the "tiapp.xml" file, and then click the tab on the main area that says "tiapp.xml".
Find the line that says "<navbar-hidden>false</navbar-hidden>" and change the "false" to "true".
Save the file and close it.

TESTING IT:

If you have an Android phone, the easiest way to test your game is to publish the real APK file and copy it to your phone (dropbox is an amazing tool for this - you can just open the apk file in the dropbox app and it'll install).
Click the button with the brown box, select "Distribute - Android App Store", and fill out the distribute form that comes up. If you're having trouble, I'll go over this window in more detail in the next section.
Click publish, and you should end up with an APK file to install on your phone.

If you have an iPhone, you'll need: An apple computer with xCode, so you can test it in the xCode simulator.
Above the files window on the left, click the button with a green play icon and a folder. From that menu, select "iPad Simulator" or "iPhone Simulator" - that should launch the simulator, and automatically open your game.

You'll probably notice in the folders there's a TON of jpg and png files - these are the icons/splash/loading screens for all the different sizes your game might get played on. You can replace these files with whatever you like, but they need to be the same size/type as what's in there.

7) ADD THE VIBRATE MACRO TO YOUR STORY (only if you plan on putting it on a phone, at the moment it gives an error if you use it on its own)

try {  	version.extensions['vibrate'] = {   		major:1, minor:0, revision:0   	};  	macros['vibrate'] = {  		handler: function(place, macroName, params, parser) {  			Titanium.App.fireEvent('vibratePhone', {type:params[0]});  		},  		init: function() { },  	};  } catch(e) {  	throwError(place,"vibrate Setup Error: "+e.message);   }  

call it with <<vibrate "TYPE">> where "TYPE" can be "short","long","single","double", or "triple"

Next: Getting your twine game onto Google Play