Class JigsawPuzzle

java.lang.Object
net.dermetfan.gdx.scenes.scene2d.ui.JigsawPuzzle

public class JigsawPuzzle
extends java.lang.Object
represents a puzzle and manages Pieces
Since:
0.10.0
  • Constructor Details

    • JigsawPuzzle

      public JigsawPuzzle()
    • JigsawPuzzle

      public JigsawPuzzle​(int pieces)
      Parameters:
      pieces - the amount of pieces that will probably be in this puzzle
    • JigsawPuzzle

      public JigsawPuzzle​(JigsawPuzzle.Piece... pieces)
      Parameters:
      pieces - the pieces
  • Method Details

    • solve

      public void solve​(JigsawPuzzle.Piece relativeTo)
      solves the puzzle by letting all pieces snap into their spot
      Parameters:
      relativeTo - the piece relative to which the puzzle should be solved
    • add

      public void add​(JigsawPuzzle.Piece piece)
      Parameters:
      piece - the piece to add to pieces
    • remove

      public boolean remove​(JigsawPuzzle.Piece piece)
      Parameters:
      piece - the piece to remove from pieces
      Returns:
      if the piece was found and removed
    • findClosest

      @Deprecated public JigsawPuzzle.Piece findClosest​(JigsawPuzzle.Piece piece)
      Deprecated.
      no known use case
      Parameters:
      piece - the piece to which to find the closest other piece
      Returns:
      the piece most correctly placed in relation to the given piece
    • isSolved

      public boolean isSolved​(float tolerance)
      Parameters:
      tolerance - the distance by which each piece is allowed to be off
      Returns:
      if the puzzle is solved
    • solved

      protected void solved()
      called by placed when all pieces are placed correctly
    • getPieces

      public com.badlogic.gdx.utils.Array<JigsawPuzzle.Piece> getPieces()
      Returns:
      the pieces