posl = new Vector2(rand.nextInt(FLUC) , y); posr = new Vector2(posl.x - right.getWidth() , y); boundsleft = new Rectangle(posl.x, posl.y, left.getWidth(),left.getHeight()); boundsright = new Rectangle(posr.x, posr.y, right.getWidth(), right.getHeight()); public boolean overlaps(Rectangle rb){ return rb.overlaps(boundsleft) || rb.overlaps(boundsright); } 

These are lines from the Block class. From the very logic of the game:

 for (Block tube : tubes) { if(tube.overlaps(Player.getRect()){ dm.set(new OtherState(dm)); } 

Well and creation Rect in class Player

 rect = new Rectangle(x, y, player.getWidth(),player.getHeight()); 

tubes here is an Array Block> .dm object - abbr. from display manager - a stack of screen states. set (dm) method - combining the pop (dm) and push () methods.

  • how to understand does not work? describe the problem in more detail - Senior Pomidor
  • Does not respond to the event. In theory, it should change the screen state, but this does not happen. - artur dinanmitt
  • First you need to understand what exactly does not work: if (tube.overlaps (Player.getRect ()) or dm.set (new OtherState (dm)). Write a message in front of set.dm using System.out ... then it will be clearer - Konstantin

0