2014-01-30 2 views
0

В основном, что я пытаюсь сделать, это изменить лицо, когда я навис над ним. Все компилируется, но по какой-то причине, когда курсор находится над координатами, лицо остается неизменным. Я не уверен, если это что-то делать с не используя настройки или рисовать методы, но я все еще получаю ту же проблему, когда я добавляю те, в.Обработка: попытка получить лицо для изменения с помощью мыши.

size(600, 400); 
background(49, 185, 232); 
noStroke(); 
smooth(8); 

//Loop that determines if face is scared or unsuspecting based off of mouse position. 
if(mouseX>200 && mouseY<400) 
{ 
//Scared Face 
//Intializing head position data 
    int headX=300; 
    int headY=200; 
    int headSize=200; 
//Actual head rendering 
    fill(255, 196, 77); 
    ellipse(headX, headY, headSize, headSize); 

//Intializing nose position data 
    int noseTopX=300; 
    int noseTopY=200; 
    int noseLX=280; 
    int noseLY=220; 
    int noseRX=320; 
    int noseRY=220; 
//Rendering of nose 
    fill(245, 74, 86); 
    triangle(noseTopX, noseTopY, noseLX, noseLY, noseRX, noseRY); 

//Intializing mouth position data 
    int mouthLX=260; 
    int mouthLY=250; 
    int mouthRX=340; 
    int mouthRY=250; 
//Mouth Rendering 
    stroke(1); 
    strokeWeight(40); 
    line(mouthLX, mouthLY, mouthRX, mouthRY); 

//Getting rid of stroke 
    noStroke(); 

//Initializing Left Eye position 
    int eyeLX=250; 
    int eyeLY=170; 
    int eyeLSize1=75; 
    int eyeLSize2=50; 
    int pupilL=50; 
//Initializing Left Eye 
    fill(250); 
    ellipse(eyeLX, eyeLY, eyeLSize1, eyeLSize2); 
    fill(1); 
    ellipse(eyeLX, eyeLY, pupilL, pupilL); 

//Initializing Right 
    int eyeRX=350; 
    int eyeRY=170; 
    int eyeRSize1=75; 
    int eyeRSize2=50; 
    int pupilR=30; 
//Initializing Right Eye 
    fill(250); 
    ellipse(eyeRX, eyeRY, eyeRSize1, eyeRSize2); 
    fill(1); 
    ellipse(eyeRX, eyeRY, pupilR, pupilR); 
} 
else 
{ 
//Unsuspected Face 
//Intializing Head Data 
    int headX=300; 
    int headY=200; 
    int headSize=200; 
//Actual head rendering 
    fill(255, 196, 77); 
    ellipse(headX, headY, headSize, headSize); 

//Intializing nose position data 
    int noseTopX=300; 
    int noseTopY=200; 
    int noseLX=280; 
    int noseLY=220; 
    int noseRX=320; 
    int noseRY=220; 
//Rendering of nose 
    fill(245, 74, 86); 
    triangle(noseTopX, noseTopY, noseLX, noseLY, noseRX, noseRY); 

//Intializing mouth position data 
    int mouthLX=260; 
    int mouthLY=250; 
    int mouthRX=340; 
    int mouthRY=250; 
//Mouth Rendering 
    stroke(1); 
    strokeWeight(4); 
    line(mouthLX, mouthLY, mouthRX, mouthRY); 

//Getting rid of stroke 
    noStroke(); 

//Initializing Left Eye position 
    int eyeLX=250; 
    int eyeLY=170; 
    int eyeLSize1=45; 
    int eyeLSize2=30; 
    int pupilL=10; 
//Initializing Left Eye 
    fill(250); 
    ellipse(eyeLX, eyeLY, eyeLSize1, eyeLSize2); 
    fill(1); 
    ellipse(eyeLX, eyeLY, pupilL, pupilL); 

//Initializing Right 
    int eyeRX=350; 
    int eyeRY=170; 
    int eyeRSize1=45; 
    int eyeRSize2=30; 
    int pupilR=10; 
//Initializing Right Eye 
    fill(250); 
    ellipse(eyeRX, eyeRY, eyeRSize1, eyeRSize2); 
    fill(1); 
    ellipse(eyeRX, eyeRY, pupilR, pupilR); 
} 

ответ

1

с обработкой, если вы хотите, чтобы делать вещи после самый первый кадр, вы должны включить явный метод draw(). Просто добавив setup() и draw() к вашему коду, вы можете взаимодействовать. Обратите внимание, что области для изменения лица выглядят неправильно закодированными, но, возможно, это так, как вы планировали.

void setup() { 
    size(600, 400); 
    background(49, 185, 232); 
    noStroke(); 
    smooth(8); 
} 
void draw() { 
    //Loop that determines if face is scared or unsuspecting based off of mouse position. 
    if (mouseX>200 && mouseY<400) 
    { 
    //Scared Face 
    //Intializing head position data 
    int headX=300; 
    int headY=200; 
    int headSize=200; 
    //Actual head rendering 
    fill(255, 196, 77); 
    ellipse(headX, headY, headSize, headSize); 

    //Intializing nose position data 
    int noseTopX=300; 
    int noseTopY=200; 
    int noseLX=280; 
    int noseLY=220; 
    int noseRX=320; 
    int noseRY=220; 
    //Rendering of nose 
    fill(245, 74, 86); 
    triangle(noseTopX, noseTopY, noseLX, noseLY, noseRX, noseRY); 

    //Intializing mouth position data 
    int mouthLX=260; 
    int mouthLY=250; 
    int mouthRX=340; 
    int mouthRY=250; 
    //Mouth Rendering 
    stroke(1); 
    strokeWeight(40); 
    line(mouthLX, mouthLY, mouthRX, mouthRY); 

    //Getting rid of stroke 
    noStroke(); 

    //Initializing Left Eye position 
    int eyeLX=250; 
    int eyeLY=170; 
    int eyeLSize1=75; 
    int eyeLSize2=50; 
    int pupilL=50; 
    //Initializing Left Eye 
    fill(250); 
    ellipse(eyeLX, eyeLY, eyeLSize1, eyeLSize2); 
    fill(1); 
    ellipse(eyeLX, eyeLY, pupilL, pupilL); 

    //Initializing Right 
    int eyeRX=350; 
    int eyeRY=170; 
    int eyeRSize1=75; 
    int eyeRSize2=50; 
    int pupilR=30; 
    //Initializing Right Eye 
    fill(250); 
    ellipse(eyeRX, eyeRY, eyeRSize1, eyeRSize2); 
    fill(1); 
    ellipse(eyeRX, eyeRY, pupilR, pupilR); 
    } 
    else 
    { 
    //Unsuspected Face 
    //Intializing Head Data 
    int headX=300; 
    int headY=200; 
    int headSize=200; 
    //Actual head rendering 
    fill(255, 196, 77); 
    ellipse(headX, headY, headSize, headSize); 

    //Intializing nose position data 
    int noseTopX=300; 
    int noseTopY=200; 
    int noseLX=280; 
    int noseLY=220; 
    int noseRX=320; 
    int noseRY=220; 
    //Rendering of nose 
    fill(245, 74, 86); 
    triangle(noseTopX, noseTopY, noseLX, noseLY, noseRX, noseRY); 

    //Intializing mouth position data 
    int mouthLX=260; 
    int mouthLY=250; 
    int mouthRX=340; 
    int mouthRY=250; 
    //Mouth Rendering 
    stroke(1); 
    strokeWeight(4); 
    line(mouthLX, mouthLY, mouthRX, mouthRY); 

    //Getting rid of stroke 
    noStroke(); 

    //Initializing Left Eye position 
    int eyeLX=250; 
    int eyeLY=170; 
    int eyeLSize1=45; 
    int eyeLSize2=30; 
    int pupilL=10; 
    //Initializing Left Eye 
    fill(250); 
    ellipse(eyeLX, eyeLY, eyeLSize1, eyeLSize2); 
    fill(1); 
    ellipse(eyeLX, eyeLY, pupilL, pupilL); 

    //Initializing Right 
    int eyeRX=350; 
    int eyeRY=170; 
    int eyeRSize1=45; 
    int eyeRSize2=30; 
    int pupilR=10; 
    //Initializing Right Eye 
    fill(250); 
    ellipse(eyeRX, eyeRY, eyeRSize1, eyeRSize2); 
    fill(1); 
    ellipse(eyeRX, eyeRY, pupilR, pupilR); 
    } 
} 
+0

Спасибо, я пробовал это раньше, но я продолжал получать ошибки компилятора. –

Смежные вопросы