Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //libraries demo
- //import necessary libraries
- import g4p_controls.*;
- //declare necessary variables
- PImage photo;
- GImageButton myButton;
- String [] files;
- float startTime;
- boolean startScreen;
- color bgColor;
- void setup () {
- size (2560, 1600);
- //boolean to keep track of which screen draws
- startScreen = true;
- photo = loadImage("firewatch.jpg");
- //string array to store file names of button states
- files = new String [] {"Up.png", "Hover.png", "Down.png",};
- //instantiate new button (note that it takes files, the string array, as an argument)
- myButton = new GImageButton (this, width/2-600, height/2-600, files);
- }
- void draw () {
- if(startScreen) {
- background (photo);
- } else {
- background (0, 100, 200);
- fill ((millis()-startTime)/10*255/width, 50, 50);
- rect ((millis()-startTime)/10, height/2,100,100);
- }
- }
- //necessary function when using G4P
- void handleButtonEvents (GImageButton button, GEvent event) {
- if (button==myButton){
- //all code that covers what we want to happen when button is pressed
- println ("Button Pressed");
- myButton.dispose();
- myButton=null;
- startScreen=false;
- startTime = millis();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement