Package net.dermetfan.gdx.graphics.g2d
Class Box2DSprite
java.lang.Object
com.badlogic.gdx.graphics.g2d.TextureRegion
com.badlogic.gdx.graphics.g2d.Sprite
net.dermetfan.gdx.graphics.g2d.Box2DSprite
- Direct Known Subclasses:
 AnimatedBox2DSprite
public class Box2DSprite
extends com.badlogic.gdx.graphics.g2d.Sprite
A 
Box2DSprite is a Sprite 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 Box2DSprites in the user data of Fixtures.- 
Field Summary
Fields Modifier and Type Field Description static net.dermetfan.utils.Function<java.lang.Object,Box2DSprite>defaultUserDataAccessortheuserDataAccessorused by default - 
Constructor Summary
Constructors Constructor Description Box2DSprite()Box2DSprite(com.badlogic.gdx.graphics.g2d.Sprite sprite)Box2DSprite(com.badlogic.gdx.graphics.g2d.TextureRegion region)Box2DSprite(com.badlogic.gdx.graphics.g2d.TextureRegion region, int srcX, int srcY, int srcWidth, int srcHeight)Box2DSprite(com.badlogic.gdx.graphics.Texture texture)Box2DSprite(com.badlogic.gdx.graphics.Texture texture, int srcWidth, int srcHeight)Box2DSprite(com.badlogic.gdx.graphics.Texture texture, int srcX, int srcY, int srcWidth, int srcHeight) - 
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 thisBox2DSpriteon the givenBodyvoiddraw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.Fixture fixture)draws thisBox2DSpriteon 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 theBox2DSpriteson theBodyorFixturethat hold them in their user data in the givenWorldstatic net.dermetfan.utils.Function<?,Box2DSprite>getUserDataAccessor()static java.util.Comparator<Box2DSprite>getZComparator()floatgetZIndex()booleanisAdjustHeight()booleanisAdjustWidth()booleanisUseOriginX()booleanisUseOriginY()voidsetAdjustHeight(boolean adjustHeight)voidsetAdjustSize(boolean adjustSize)voidsetAdjustWidth(boolean adjustWidth)voidsetHeight(float height)voidsetUseOrigin(boolean useOrigin)voidsetUseOriginX(boolean useOriginX)voidsetUseOriginY(boolean useOriginY)static voidsetUserDataAccessor(net.dermetfan.utils.Function<java.lang.Object,Box2DSprite> userDataAccessor)voidsetWidth(float width)static voidsetZComparator(java.util.Comparator<Box2DSprite> zComparator)voidsetZIndex(float zIndex)Methods inherited from class com.badlogic.gdx.graphics.g2d.Sprite
draw, draw, flip, getBoundingRectangle, getColor, getHeight, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getVertices, getWidth, getX, getY, rotate, rotate90, scale, scroll, set, setAlpha, setBounds, setCenter, setCenterX, setCenterY, setColor, setColor, setFlip, setOrigin, setOriginBasedPosition, setOriginCenter, setPackedColor, setPosition, setRegion, setRotation, setScale, setScale, setSize, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateYMethods inherited from class com.badlogic.gdx.graphics.g2d.TextureRegion
getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, splitMethods 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,Box2DSprite> defaultUserDataAccessortheuserDataAccessorused by default 
 - 
 - 
Constructor Details
- 
Box2DSprite
public Box2DSprite()- See Also:
 Sprite()
 - 
Box2DSprite
public Box2DSprite(com.badlogic.gdx.graphics.Texture texture, int srcWidth, int srcHeight)- See Also:
 Sprite(Texture, int, int)
 - 
Box2DSprite
public Box2DSprite(com.badlogic.gdx.graphics.Texture texture, int srcX, int srcY, int srcWidth, int srcHeight)- See Also:
 Sprite(Texture, int, int, int, int)
 - 
Box2DSprite
public Box2DSprite(com.badlogic.gdx.graphics.g2d.TextureRegion region, int srcX, int srcY, int srcWidth, int srcHeight)- See Also:
 Sprite(TextureRegion, int, int, int, int)
 - 
Box2DSprite
public Box2DSprite(com.badlogic.gdx.graphics.Texture texture)- See Also:
 Sprite(Texture)
 - 
Box2DSprite
public Box2DSprite(com.badlogic.gdx.graphics.g2d.TextureRegion region)- See Also:
 Sprite(TextureRegion)
 - 
Box2DSprite
public Box2DSprite(com.badlogic.gdx.graphics.g2d.Sprite sprite)- See Also:
 Sprite(Sprite)
 
 - 
 - 
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 theBox2DSpriteson theBodyorFixturethat hold them in their user data in the givenWorld - 
draw
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.Fixture fixture)draws thisBox2DSpriteon the givenFixture - 
draw
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.physics.box2d.Body body)draws thisBox2DSpriteon 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 thisBox2DSpritein 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 beSprite.width*Sprite.heightinstead of the given size.
The drawing position of the sprite is always the bottom left of the body or fixture.- Parameters:
 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
 - 
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
 - 
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)
 - 
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,Box2DSprite> userDataAccessor)- Parameters:
 userDataAccessor- theuserDataAccessorto set
 
 -