Code:
Screen screen1, screen2;
Image[] _Images;
ImageButton[] _ImageButtons;
TextBox[] _TextBoxes;
TextBoxButton[] _TextBoxButtons;
String _Sound;
PFont fontA;
Screen current_screen;
void setup()
{
size(800,600);
smooth();
background(255);
/* ------------------------------Edit from here---------------------*/
// Images for screen 1
_Images = new Image[2]; // 2: How many Images are used in this screen
_Images[0] = new Image("image1.jpg", 0, 0); // First image for screen 1 is image1.jpg placed on 0 pixels X and 0 pixels Y
_Images[1] = new Image("image2.jpg", 100, 100);
// ImageButtons for screen 1
_ImageButtons = new ImageButton[1]; // 1: How many ImageButtons are used in this screen
_ImageButtons[0] = new ImageButton("image1.jpg", 0, 0, screen2); // First image links to screen 2 (doesn't work YET)
// Textboxes for screen 1
_TextBoxes = new TextBox[1];
_TextBoxes[0] = new TextBox("Test", 200, 200); // First textbox placed on X,Y(200,200) with the text "Test"
// TextboxButtons for screen 1
_TextBoxButtons = new TextBoxButton[1];
_TextBoxButtons[0] = new TextBoxButton("TestLink", 300, 300, screen2);
// Set sound for screen 1
_Sound = "sound.mp3";
// Finally Set Screen 1
screen1 = new Screen(_Images, _ImageButtons, _TextBoxes, _TextBoxButtons, _Sound);
/* ----------------------------Do not edit from here--------------*/
current_screen = screen1;
}
void draw()
{
DisplayScreen();
}
class Screen
{
Image[] Images;
TextBox[] TextBoxes;
Screen(Image[] _Images, ImageButton[] _ImageButtons, TextBox[] _TextBoxes, TextBoxButton[] _TextBoxButtons, String _Sound)
{
Images = _Images;
TextBoxes = _TextBoxes;
}
void set()
{
}
void display()
{
for(int i=0; i < Images.length; i++){
Images[i].display();
}
}
}
class Image
{
int x, y;
String file;
Image(String ifile, int ix, int iy) {
x = ix;
y = iy;
file = ifile;
}
void display() {
PImage loadimage = loadImage("Images/" + file);
image(loadimage, x, y);
}
}
class ImageButton
{
int x, y;
String file;
Screen screen;
ImageButton(String _file, int _x, int _y, Screen _screen) {
x = _x;
y = _y;
file = _file;
screen = _screen;
}
void display() {
PImage loadimage = loadImage("Images/" + file);
image(loadimage, x, y);
}
// void to link Button to Screen
}
class TextBox
{
int x, y;
String text;
TextBox(String _text, int _x, int _y) {
x = _x;
y = _y;
text = _text;
}
void display() {
String text;
fontA = loadFont("AgencyFB-Bold-48.vlw");
textFont(fontA);
fill(0);
}
}
class TextBoxButton
{
int x, y;
String text;
Screen screen;
TextBoxButton(String _text, int _x, int _y, Screen _screen) {
x = _x;
y = _y;
text = _text;
screen = _screen;
}
void display() {
// code to display textbox
}
// void to link Button to Screen
}
void DisplayScreen(){
current_screen.display();
}
Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum