clicking images and running functions

edited May 2016 in How To...

hello everyone, im doing a space invader like game, but this one has a selection screen like street fighter & mortal combat for selecting ships.

i defined the specific coordinates for specific images and wrote the code for this but when i clicked code is running but when i released im turning back to select screen.

how can i make this function permanent ?

sorry for grammer btw im'not native !

Answers

  • Answer ✓

    You need a state system where you say you are in stateSelectShip and then in stateGame

    Where your mousePressed occurs say

    state = stateGame;

    before setup()

    final int stateGame=1;

    int state=stateGame;

    in draw say switch(state){ and act accordingly- nothing is allowed in draw() outside that switch

Sign In or Register to comment.