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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJigsawPuzzle.Piecea piece on aJigsawPuzzleclassJigsawPuzzle.SourceclassJigsawPuzzle.Target -
Constructor Summary
Constructors Constructor Description JigsawPuzzle()JigsawPuzzle(int pieces)JigsawPuzzle(JigsawPuzzle.Piece... pieces) -
Method Summary
Modifier and Type Method Description voidadd(JigsawPuzzle.Piece piece)JigsawPuzzle.PiecefindClosest(JigsawPuzzle.Piece piece)Deprecated.no known use casecom.badlogic.gdx.utils.Array<JigsawPuzzle.Piece>getPieces()booleanisSolved(float tolerance)booleanremove(JigsawPuzzle.Piece piece)voidsolve(JigsawPuzzle.Piece relativeTo)solves the puzzle by letting allpiecessnapinto their spotprotected voidsolved()called byplacedwhen all pieces are placed correctlyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
JigsawPuzzle
public JigsawPuzzle() -
JigsawPuzzle
public JigsawPuzzle(int pieces)- Parameters:
pieces- the amount of pieces that will probably be in this puzzle
-
JigsawPuzzle
- Parameters:
pieces- thepieces
-
-
Method Details
-
solve
solves the puzzle by letting allpiecessnapinto their spot- Parameters:
relativeTo- the piece relative to which the puzzle should be solved
-
add
- Parameters:
piece- the piece to add topieces
-
remove
- Parameters:
piece- the piece to remove frompieces- Returns:
- if the piece was found and removed
-
findClosest
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 byplacedwhen all pieces are placed correctly -
getPieces
- Returns:
- the
pieces
-