Frist of all we imported the “phone” library:
import processing.phone.*;
Phone myPhone;
We declared all the needed integer variable and divided in separate blocks to make the code more legible.
The variable of the logo and the main manu screens:
int SECTION_LOGO = 0;
int SECTION_MAINMENU = 1;
int SECTION_EVENTS = 2;
int SECTION_SEARCH = 3;
int SECTION_MYEVENTS = 4;
int SECTION_TORCH = 5;
the variable of the focus on the four options on the main menu:
int MAINMENU_EVENTS = 0;
int MAINMENU_SEARCH = 1;
int MAINMENU_MYEVENTS = 2;
int MAINMENU_TORCH = 3;
two variable of the first and the second levels of “MY EVENTS” session:
int MYEVENTS_MENU = 0;
int MYEVENTS_DETAIL = 1;
the variable of the focus on the four different options of the “MY EVENTS” menu:
int MYEVENTS_MENU_EVENT0 = 0;
int MYEVENTS_MENU_EVENT1 = 1;
int MYEVENTS_MENU_EVENT2 = 2;
int MYEVENTS_MENU_EVENT3 = 3;
the variable of the second level mode in ” MY EVENTS” session:
int MYEVENTS_DETAIL_EVENT0 = 0;
int MYEVENTS_DETAIL_EVENT1 = 1;
int MYEVENTS_DETAIL_EVENT2 = 2;
int MYEVENTS_DETAIL_EVENT3 = 3;
the variable of the “SEARCH MODE” session:
int SCREEN_POPUP = 0;
int SCREEN_MAPPA = 1;
int SCREEN_FUMETTO = 0;
of the “TOCH MODE” session:
int TORCH_OPENING = 0;
int TORCH_INFO = 1;
int TORCH_MAP = 2;
int TORCH_MAP_STAGE0 = 0;
int TORCH_MAP_STAGE1 = 1;
int TORCH_MAP_STAGE2 = 2;
int TORCH_MAP_STAGE3 = 3;
int TORCH_MAP_STAGE4 = 4;
/////////////////////////////////////////////////////////////////////////////////////////////
Here we wrote all the variables which are controlling each screen:
int sectionMode =Â SECTION_LOGO;
int mainmenuFocus = MAINMENU_EVENTS;
int eventsMode = 0;
int eventsModeMovie = 0;
int myeventsMode = MYEVENTS_MENU;
int myeventsmenuFocus = MYEVENTS_MENU_EVENT0;
int myeventsdetailMode = MYEVENTS_DETAIL_EVENT0;
int torchMode = TORCH_OPENING;
int torchMapMode = TORCH_MAP_STAGE0;
int searchMode = SCREEN_POPUP;
int searchFocus = SCREEN_FUMETTO;
/////////////////////////////////////////////////////////////////////////////////////////////
Everything into the void setup () happens just once. Intersting is to note the function myPhone.fullscreen () which enlarges the fullscreen mode. Here all general functions are called:
void setup()
{
myPhone = new Phone(this);
myPhone.fullscreen();
loadFonts();
loadImages();
updateLightPosition();
initializeTorchVars();
initializeEventSchedules();
initializeEventsVars();
}
/////////////////////////////////////////////////////////////////////////////////////////////
Contrary, all the functions into the void draw () are called repeatitly. Here we wrote the functions which are loading, drawing and unloading the screens through conditional logics.
Because our code it was to heavy and it could not run on mobile phone we had to structure the code in this way. We created separate functions to upload each images session and to unload them after the use:
void draw()
{
if((sectionMode == SECTION_EVENTS)||(sectionMode == SECTION_MYEVENTS)){
loadAllEventsImages();
}
else if(sectionMode == SECTION_TORCH){
loadTorchImages();
}else{
unloadAllEventsImages();
unloadTorchImages();
}
if(sectionMode == SECTION_LOGO){
drawSectionLogo();
}
else if(sectionMode == SECTION_MAINMENU){
drawSectionMainmenu();
}
else if(sectionMode == SECTION_EVENTS){
drawSectionEvents();
}
else if(sectionMode == SECTION_SEARCH){
drawSectionSearch();
}
else if(sectionMode == SECTION_MYEVENTS){
drawSectionMyevents();
}
else if(sectionMode == SECTION_TORCH){
drawSectionTorch();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
The code below it inizializes all the schedules information into the “EVENTS” session. We used two array to store all those info, beacuse we need that each “EVENTS” page has different schedules:
void initializeEventSchedules(){
events_schedules[0][0] = “Monday\n20:30 - 23:30″;
events_schedules[0][1] = “Tuesday\n20:30 - 23:30″;
events_schedules[0][2] = “Friday\n21:00 - 23:30″;
events_schedules[0][3] = “Saturday\n21:00 - 23:30″;
etc.
This is related to the “TORCH” session and initializes the two arrays with two “for” loops. Each of them assigns randomly the x and y values of the Confetti positions:
void initializeTorchVars(){
int i;
for(i = 0; i < 100; ++i){
mapConfettiPositions0[i][0] = random(0, width);
mapConfettiPositions0[i][1] = random(-height, 0);
}
for(i = 0; i < 6; ++i){
mapConfettiPositions1[i][0] = random(0, width);
mapConfettiPositions1[i][1] = random(-height, 0);
}
}
In this function are stored all the information about the scrolling previews from the “EVENTS” session. It was used two arrays to make the code lighter:
void initializeEventsVars(){
events_descriptions[0][0] = “I Short-film\n\n-A beautiful day-\nJonny Jolly\nThailand 2008\n3′33””;
events_images_counts[0] = 1;
etc.
This is an intersting one: it is a function which has the task to collect and delete the unuploaded images:
void collectGarbage(){
//System.gc();
Runtime r = Runtime.getRuntime();
r.gc();
}
| Cinomadic | how it works … | circuito off | corporate identity | users + stakeholders | technologies | code > logic > graphics > behavior | early investigations | credits | downloads |