Class JigsawPuzzle.Piece

java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.badlogic.gdx.scenes.scene2d.ui.Image
net.dermetfan.gdx.scenes.scene2d.ui.JigsawPuzzle.Piece
All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Layout
Enclosing class:
JigsawPuzzle

public static class JigsawPuzzle.Piece
extends com.badlogic.gdx.scenes.scene2d.ui.Image
a piece on a JigsawPuzzle
Since:
0.10.0
  • Constructor Summary

    Constructors
    Constructor Description
    Piece​(com.badlogic.gdx.scenes.scene2d.utils.Drawable drawable)  
  • Method Summary

    Modifier and Type Method Description
    float getSlotX()  
    float getSlotY()  
    com.badlogic.gdx.scenes.scene2d.Actor hit​(float x, float y, boolean touchable)  
    boolean isPlacedCorrectly​(JigsawPuzzle.Piece reference, float tolerance)  
    void place​(JigsawPuzzle.Piece reference)  
    void setDrawable​(com.badlogic.gdx.scenes.scene2d.utils.Drawable drawable)  
    void setSlot​(float slotX, float slotY)  
    void setSlotX​(float slotX)  
    void setSlotY​(float slotY)  

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Image

    draw, getAlign, getDrawable, getImageHeight, getImageWidth, getImageX, getImageY, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, layout, setAlign, setDrawable, setScaling, toString

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget

    getMaxHeight, getMaxWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor

    act, addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Piece

      public Piece​(com.badlogic.gdx.scenes.scene2d.utils.Drawable drawable)
  • Method Details

    • setDrawable

      public void setDrawable​(com.badlogic.gdx.scenes.scene2d.utils.Drawable drawable)
      Overrides:
      setDrawable in class com.badlogic.gdx.scenes.scene2d.ui.Image
      Parameters:
      drawable - Sets the slot to the drawable's polygonX and polygonY if the given drawable is a PolygonRegionDrawable. Otherwise sets it to 0:0.
    • hit

      public com.badlogic.gdx.scenes.scene2d.Actor hit​(float x, float y, boolean touchable)
      Overrides:
      hit in class com.badlogic.gdx.scenes.scene2d.Actor
    • place

      public void place​(JigsawPuzzle.Piece reference)
      Parameters:
      reference - the piece in relation to which to this piece should snap in its spot
    • isPlacedCorrectly

      public boolean isPlacedCorrectly​(JigsawPuzzle.Piece reference, float tolerance)
      Parameters:
      reference - the piece in relation to which this piece's position should be checked
      tolerance - the distance by which each piece is allowed to be off
      Returns:
      if this piece is placed correctly in relation to the given reference piece with the given tolerance
    • setSlot

      public void setSlot​(float slotX, float slotY)
      Parameters:
      slotX - the slotX to set
      slotY - the slotY to set
    • getSlotX

      public float getSlotX()
      Returns:
      the slotX
    • setSlotX

      public void setSlotX​(float slotX)
      Parameters:
      slotX - the slotX to set
    • getSlotY

      public float getSlotY()
      Returns:
      the slotY
    • setSlotY

      public void setSlotY​(float slotY)
      Parameters:
      slotY - the slotY to set