是的,出于某种原因,当我运行我的代码时,它需要超过2GB才能运行。它可能有一些东西应该被画了很多次或什么的图片,但我不确定。 如果有人能向我解释为什么会这样,我会非常感激!
import gifAnimation.*; //imports functions from the Gif Animation library
PImage Animation, BackButton, ProgrammingIMG, CommunicationIMG, GamedevIMG, GraphicsIMG, VideoIMG, SoundIMG, Medialogy;
boolean ProgrammingClick, CommunicationClick, GamedevClick, GraphicsClick, VideoDevClick, SoundDevClick, MedialogyClick = false;
int stage; //creates a integer variable called stage.
Gif Frontpage;
void setup() { //we load all the images beforehand to reduce load time.
size(1415, 1000); //size of window
frameRate(100); //framerate of the gifs
smooth(); //anti-aliased edges and smoother images when resized.
BackButton = loadImage("Go_back_button.png");
GamedevIMG = loadImage("1_Game_development.jpg");
ProgrammingIMG = loadImage("2_Programming.jpg");
VideoIMG = loadImage("3_Video_production.jpg");
SoundIMG = loadImage("4_Sound_and_music_computing.jpg");
CommunicationIMG = loadImage("5_communication.jpg");
GraphicsIMG = loadImage("6_graphic_design.jpg");
Medialogy = loadImage("7_medialogy.jpg");
Frontpage = new Gif(this,"0_BigGif.gif");
Frontpage. loop(); //makes the gif loop.
stage = 1; //The app starts in stage 1
}
void draw() {
if(SoundDevClick==true && stage==1){ //sound
stage=3;
image(SoundIMG, 0, 0, width, height);
image(BackButton,15,930);
}
else if(MedialogyClick==true && stage==1){ //If the boolean (MedialogyClick) is true, and we are in stage one, we will go to stage 2.
stage=2;
image(Medialogy, 0, 0, width, height);
image(BackButton,15,930);
}
else if(ProgrammingClick==true && stage==1){ //programming
stage=4;
image(ProgrammingIMG, 0, 0, width, height);
image(BackButton,15,930);
}
else if(GamedevClick==true && stage==1){ //gamedev
stage=5;
image(GamedevIMG, 0, 0, width, height);
image(BackButton,15,930);
}
else if(GraphicsClick==true && stage==1){ //graphics
stage=6;
image(GraphicsIMG, 0, 0, width, height);
image(BackButton,15,930);
}
else if(VideoDevClick==true && stage==1){ //videodev
stage=7;
image(VideoIMG, 0, 0, width, height);
image(BackButton,15,930);
}
else if(CommunicationClick==true && stage==1){ //communication
stage=8;
image(CommunicationIMG, 0, 0, width, height);
image(BackButton,15,930);
}
else if(stage==1){ //if the program is in stage 1, the main page will be shown.
image(Frontpage, 0,0, width, height);
}
else if(SoundDevClick==false){ //If the boolean SoundDevClick is false, stage 1 will be called, and we will now be in stage 1.
stage=1;
}
else if(GamedevClick==false){
stage=1;
}
else if(GraphicsClick==false){
stage=1;
}
else if(CommunicationClick==false){
stage=1;
}
else if(ProgrammingClick==false){
stage=1;
}
else if(MedialogyClick==false){
stage=1;
}
else if(VideoDevClick==false){
stage=1;
}
}
void mousePressed() { //if the mouse is pressed it will state Clicked as true, therefore opening the image "Open.png", but only if the "if" statement is true.
if (mouseX>300 && mouseX<550 && mouseY>230 && mouseY<450 && mouseButton == LEFT && stage ==1) { //If the mouse is within the defined parameters, and the left mousebutton is pressed, SoundDevClick will be set as true.
SoundDevClick=true; //Music
}
if (mouseX>700 && mouseX<930 && mouseY>745 && mouseY<980 && mouseButton == LEFT && stage ==1) { //GameDev
GamedevClick=true;
}
if (mouseX>1000 && mouseX<1320 && mouseY>320 && mouseY<600 && mouseButton == LEFT && stage ==1) { //Graphics
GraphicsClick=true;
}
if (mouseX>40 && mouseX<270 && mouseY>355 && mouseY<790 && mouseButton == LEFT && stage ==1) { //Video Dev
VideoDevClick=true;
}
if (mouseX>540 && mouseX<960 && mouseY>190 && mouseY<470 && mouseButton == LEFT && stage ==1) { //Communication
CommunicationClick=true;
}
if (mouseX>400 && mouseX<650 && mouseY>500 && mouseY<790 && mouseButton == LEFT && stage ==1) { //Programming
ProgrammingClick=true;
}
if (mouseX>470 && mouseX<950 && mouseY>15 && mouseY<115 && mouseButton == LEFT && stage ==1) { //Medialogy
MedialogyClick=true;
}
else if (mouseX>0 && mouseX<240 && mouseY>910 && mouseY<1000 && mouseButton == LEFT) { //If left mousebutton is pressed within parameters, it will set following booleans as false (Resulting in going back to stage 1).
SoundDevClick=false;
GamedevClick=false;
GraphicsClick=false;
CommunicationClick=false;
ProgrammingClick=false;
MedialogyClick=false;
VideoDevClick=false;
}
}