Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Processing - change image on click

  • 01-04-2014 4:06pm
    #1
    Registered Users Posts: 2,589 ✭✭✭


    Im doing a little project using Processing which has a play button which moves a vertical line across the screen which creates a different sound depending on what lines are drawn. What I want to happen is have a pause button image appear when the play image is clicked and vice versa. So when it is stopped, the play image is visible and when it is playing, the pause button is visible.

    I have it working for the Play button, which also stops as i have the code set up in a way saying that if the mouse is clicked within the co-ords of the image, it will play or stop it.

    The code i have is:
    void draw()
    {
    // Show Play/Pause button
    image(play_but, 475, 370, 50, 50);
    }

    void mousePressed()
    {
    // if play/pause button is clicked
    if( (mouseX > 425 && mouseX < 525) && (mouseY > 370 && mouseY < 420))
    {
    drawing = false;
    cursor(HAND);

    if(playing == false)
    {
    playing = true;
    }
    else
    {
    playing = false;
    }
    }
    Tagged:


Advertisement