Package net.dermetfan.gdx.graphics.g2d
Class Box2DPolygonSprite
java.lang.Object
com.badlogic.gdx.graphics.g2d.PolygonSprite
net.dermetfan.gdx.graphics.g2d.Box2DPolygonSprite
public class Box2DPolygonSprite
extends com.badlogic.gdx.graphics.g2d.PolygonSprite
A 
Box2DPolygonSprite is a PolygonSprite with additional drawing information and the ability to draw itself on a given Body or Fixture.
  It is supposed to be put in the user data of Fixtures or Bodies. Because geometrical information about bodies cannot be cached, it is faster to put Box2DPolygonSprites in the user data of Fixtures.- Since:
 - 0.5.0
 
- 
Field Summary
Fields Modifier and Type Field Description static net.dermetfan.utils.Function<java.lang.Object,Box2DPolygonSprite>defaultUserDataAccessortheuserDataAccessorused by default - 
Constructor Summary
Constructors Constructor Description Box2DPolygonSprite(com.badlogic.gdx.graphics.g2d.PolygonRegion region)Box2DPolygonSprite(com.badlogic.gdx.graphics.g2d.PolygonSprite sprite) - 
Method Summary
Modifier and Type Method Description voiddraw(com.badlogic.gdx.graphics.g2d.Batch batch, float box2dX, float box2dY, float box2dWidth, float box2dHeight, float box2dRotation)Used internally.voiddraw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.Body body)draws thisBox2DPolygonSpriteon the givenBodyvoiddraw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.Fixture fixture)draws thisBox2DPolygonSpriteon the givenFixturestatic voiddraw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.World world)static voiddraw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.World world, boolean sortByZ)draws all theBox2DPolygonSpriteson theBodyorFixturethat hold them in their user data in the givenWorldvoiddraw(com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch batch, float box2dX, float box2dY, float box2dWidth, float box2dHeight, float box2dRotation)static net.dermetfan.utils.Function<?,Box2DPolygonSprite>getUserDataAccessor()static java.util.Comparator<Box2DPolygonSprite>getZComparator()floatgetZIndex()booleanisAdjustHeight()booleanisAdjustToPolygon()booleanisAdjustWidth()booleanisUseOriginX()booleanisUseOriginY()voidsetAdjustHeight(boolean adjustHeight)voidsetAdjustSize(boolean adjustSize)voidsetAdjustToPolygon(boolean adjustToPolygon)voidsetAdjustWidth(boolean adjustWidth)voidsetHeight(float height)voidsetUseOrigin(boolean useOrigin)voidsetUseOriginX(boolean useOriginX)voidsetUseOriginY(boolean useOriginY)static voidsetUserDataAccessor(net.dermetfan.utils.Function<java.lang.Object,Box2DPolygonSprite> userDataAccessor)voidsetWidth(float width)static voidsetZComparator(java.util.Comparator<Box2DPolygonSprite> zComparator)voidsetZIndex(float zIndex)Methods inherited from class com.badlogic.gdx.graphics.g2d.PolygonSprite
draw, draw, getBoundingRectangle, getColor, getHeight, getOriginX, getOriginY, getPackedColor, getRegion, getRotation, getScaleX, getScaleY, getVertices, getWidth, getX, getY, rotate, scale, set, setBounds, setColor, setColor, setOrigin, setPosition, setRegion, setRotation, setScale, setScale, setSize, setX, setY, translate, translateX, translateYMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Field Details
- 
defaultUserDataAccessor
public static final net.dermetfan.utils.Function<java.lang.Object,Box2DPolygonSprite> defaultUserDataAccessortheuserDataAccessorused by default 
 - 
 - 
Constructor Details
- 
Box2DPolygonSprite
public Box2DPolygonSprite(com.badlogic.gdx.graphics.g2d.PolygonRegion region)- See Also:
 PolygonSprite(PolygonRegion)
 - 
Box2DPolygonSprite
public Box2DPolygonSprite(com.badlogic.gdx.graphics.g2d.PolygonSprite sprite)- See Also:
 PolygonSprite(PolygonSprite)
 
 - 
 - 
Method Details
- 
draw
public static void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.World world)- See Also:
 draw(Batch, World, boolean)
 - 
draw
public static void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.World world, boolean sortByZ)draws all theBox2DPolygonSpriteson theBodyorFixturethat hold them in their user data in the givenWorld - 
getZComparator
- Returns:
 - the 
zComparator 
 - 
setZComparator
- Parameters:
 zComparator- thezComparatorto set
 - 
getUserDataAccessor
- Returns:
 - the 
userDataAccessor 
 - 
setUserDataAccessor
public static void setUserDataAccessor(net.dermetfan.utils.Function<java.lang.Object,Box2DPolygonSprite> userDataAccessor)- Parameters:
 userDataAccessor- theuserDataAccessorto set
 - 
draw
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.Fixture fixture)draws thisBox2DPolygonSpriteon the givenFixture - 
draw
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.Body body)draws thisBox2DPolygonSpriteon the givenBody - 
draw
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float box2dX, float box2dY, float box2dWidth, float box2dHeight, float box2dRotation)Used internally. Draws thisBox2DPolygonSpritein classic sprite coordinate system fashion with the given Box2D coordinates (combined with its own position, size and rotation).
IfuseOriginX/Yis enabled, theoriginwill be used instead of calculating an appropriate one for the given Box2D coordinates.
IfadjustWidth/Heightis disabled, the size of the drawing area of the sprite will bePolygonSprite.width*PolygonSprite.heightinstead of the given size.
The drawing position of the sprite is always the bottom left of the body or fixture.- Parameters:
 batch- The Batch to draw on. Redirects todraw(PolygonSpriteBatch, float, float, float, float, float)if this is an instance ofPolygonSpriteBatch.box2dX- the x coordinate (center) of the body or fixturebox2dY- the y coordinate (center) of the body or fixturebox2dWidth- the width of the body or fixturebox2dHeight- the height of the body or fixturebox2dRotation- the rotation of the body or fixture
 - 
draw
public void draw(com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch batch, float box2dX, float box2dY, float box2dWidth, float box2dHeight, float box2dRotation) - 
getZIndex
public float getZIndex()- Returns:
 - the 
zIndex 
 - 
setZIndex
public void setZIndex(float zIndex)- Parameters:
 zIndex- thezIndexto set
 - 
isAdjustWidth
public boolean isAdjustWidth()- Returns:
 - the 
adjustWidth 
 - 
setAdjustWidth
public void setAdjustWidth(boolean adjustWidth)- Parameters:
 adjustWidth- theadjustWidthto set
 - 
isAdjustHeight
public boolean isAdjustHeight()- Returns:
 - the 
adjustHeight 
 - 
setAdjustHeight
public void setAdjustHeight(boolean adjustHeight)- Parameters:
 adjustHeight- theadjustHeightto set
 - 
setAdjustSize
public void setAdjustSize(boolean adjustSize)- Parameters:
 adjustSize- theadjustWidthandadjustHeightto set
 - 
isAdjustToPolygon
public boolean isAdjustToPolygon()- Returns:
 - the 
adjustToPolygon 
 - 
setAdjustToPolygon
public void setAdjustToPolygon(boolean adjustToPolygon)- Parameters:
 adjustToPolygon- theadjustToPolygonto set
 - 
isUseOriginX
public boolean isUseOriginX()- Returns:
 - the 
useOriginX 
 - 
setUseOriginX
public void setUseOriginX(boolean useOriginX)- Parameters:
 useOriginX- theuseOriginXto set
 - 
isUseOriginY
public boolean isUseOriginY()- Returns:
 - the 
useOriginY 
 - 
setUseOriginY
public void setUseOriginY(boolean useOriginY)- Parameters:
 useOriginY- theuseOriginYto set
 - 
setUseOrigin
public void setUseOrigin(boolean useOrigin)- Parameters:
 useOrigin- theuseOriginXanduseOriginYto set
 - 
setWidth
public void setWidth(float width)- See Also:
 Sprite.setSize(float, float)
 - 
setHeight
public void setHeight(float height)- See Also:
 Sprite.setSize(float, float)
 
 -