Time for action – creating a progress bar game
In this next example a progress bar will be used for a very simple game. The idea of the game is that you have to press a button fast enough to push the progress bar back to the start. The progress bar will slowly advance towards the end and you have to constantly keep trying to move the bar back by touching a view that keeps moving around. Will you be fast enough to beat the progress bar? Perform the following steps to create a progress bar game:
Create a new blank mobile app by clicking on File | New | Titanium Project. Don't use a template as it will just generate code that gets in the way.
This application will be a single window app, so remove all of the code from
app.js
and replace it with the following:var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); // open window win1.open();
Add a progress bar to the window. Add the following creation command to the top of the file:
var progress = Ti.UI.createProgressBar...