public class Box2DSprite
extends com.badlogic.gdx.graphics.g2d.Sprite
Box2DSprite is a Sprite with additional drawing information and the abililty to draw itself on a given Body or Fixture.
It is supposed to be put in the user data of Fixtures or Bodies. The Fixture's user data is recommend though to make use of caching which will increase performance!| Modifier and Type | Field and Description |
|---|---|
private boolean |
adjustHeight
if the width and height should be adjusted to those of the
Body or Fixture this Box2DSprite is attached to (true by default) |
private boolean |
adjustWidth
if the width and height should be adjusted to those of the
Body or Fixture this Box2DSprite is attached to (true by default) |
static net.dermetfan.utils.Accessor<Box2DSprite,java.lang.Object> |
defaultUserDataAccessor
the
userDataAccessor used by default |
private boolean |
useOriginX
if the origin of this
Box2DSprite should be used when it's drawn (false by default) |
private boolean |
useOriginY
if the origin of this
Box2DSprite should be used when it's drawn (false by default) |
private static net.dermetfan.utils.Accessor<Box2DSprite,java.lang.Object> |
userDataAccessor
the
Accessor used to get a Box2DSprite from the user data of a body or fixture |
private static com.badlogic.gdx.math.Vector2 |
vec2
for internal, temporary usage
|
private float |
z
the z index for sorted drawing
|
private static java.util.Comparator<Box2DSprite> |
zComparator
|
| Constructor and Description |
|---|
Box2DSprite() |
Box2DSprite(com.badlogic.gdx.graphics.g2d.Sprite sprite) |
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) |
Box2DSprite(com.badlogic.gdx.graphics.g2d.TextureRegion region) |
Box2DSprite(com.badlogic.gdx.graphics.g2d.TextureRegion region,
int srcX,
int srcY,
int srcWidth,
int srcHeight) |
| Modifier and Type | Method and Description |
|---|---|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.physics.box2d.Body body)
draws this
Box2DSprite on the given Body |
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.physics.box2d.Fixture fixture)
draws this
Box2DSprite on the given Fixture |
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
float x,
float y,
float width,
float height,
float rotation)
draws this
Box2DSprite on the given area |
static void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.physics.box2d.World world) |
static void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.physics.box2d.World world,
boolean sortByZ)
draws all the
Box2DSprites on the Body or Fixture that hold them in their user data in the given World |
static net.dermetfan.utils.Accessor<Box2DSprite,?> |
getUserDataAccessor() |
float |
getZ() |
static java.util.Comparator<Box2DSprite> |
getZComparator() |
boolean |
isAdjustHeight() |
boolean |
isAdjustWidth() |
boolean |
isUseOriginX() |
boolean |
isUseOriginY() |
void |
setAdjustHeight(boolean adjustHeight) |
void |
setAdjustSize(boolean adjustSize) |
void |
setAdjustWidth(boolean adjustWidth) |
void |
setHeight(float height) |
void |
setUseOrigin(boolean useOrigin) |
void |
setUseOriginX(boolean useOriginX) |
void |
setUseOriginY(boolean useOriginY) |
static void |
setUserDataAccessor(net.dermetfan.utils.Accessor<Box2DSprite,java.lang.Object> userDataAccessor) |
void |
setWidth(float width) |
void |
setZ(float z) |
static void |
setZComparator(java.util.Comparator<Box2DSprite> zComparator) |
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, setColor, setFlip, setOrigin, setOriginCenter, setPosition, setRegion, setRotation, setScale, setScale, setSize, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateYgetRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, splitprivate float z
private boolean adjustWidth
Body or Fixture this Box2DSprite is attached to (true by default)private boolean adjustHeight
Body or Fixture this Box2DSprite is attached to (true by default)private boolean useOriginX
Box2DSprite should be used when it's drawn (false by default)private boolean useOriginY
Box2DSprite should be used when it's drawn (false by default)private static final com.badlogic.gdx.math.Vector2 vec2
public static final net.dermetfan.utils.Accessor<Box2DSprite,java.lang.Object> defaultUserDataAccessor
userDataAccessor used by defaultprivate static net.dermetfan.utils.Accessor<Box2DSprite,java.lang.Object> userDataAccessor
Accessor used to get a Box2DSprite from the user data of a body or fixtureprivate static java.util.Comparator<Box2DSprite> zComparator
public Box2DSprite()
Sprite.Sprite()public Box2DSprite(com.badlogic.gdx.graphics.Texture texture,
int srcWidth,
int srcHeight)
Sprite.Sprite(Texture, int, int)public Box2DSprite(com.badlogic.gdx.graphics.Texture texture,
int srcX,
int srcY,
int srcWidth,
int srcHeight)
Sprite.Sprite(Texture, int, int, int, int)public Box2DSprite(com.badlogic.gdx.graphics.g2d.TextureRegion region,
int srcX,
int srcY,
int srcWidth,
int srcHeight)
Sprite.Sprite(TextureRegion, int, int, int, int)public Box2DSprite(com.badlogic.gdx.graphics.Texture texture)
Sprite.Sprite(Texture)public Box2DSprite(com.badlogic.gdx.graphics.g2d.TextureRegion region)
Sprite.Sprite(TextureRegion)public Box2DSprite(com.badlogic.gdx.graphics.g2d.Sprite sprite)
Sprite.Sprite(Sprite)public static void draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.physics.box2d.World world)
draw(Batch, World, boolean)public static void draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.physics.box2d.World world,
boolean sortByZ)
Box2DSprites on the Body or Fixture that hold them in their user data in the given Worldpublic void draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.physics.box2d.Fixture fixture)
Box2DSprite on the given Fixturepublic void draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.physics.box2d.Body body)
Box2DSprite on the given Bodypublic void draw(com.badlogic.gdx.graphics.g2d.Batch batch,
float x,
float y,
float width,
float height,
float rotation)
Box2DSprite on the given areapublic float getZ()
zpublic void setZ(float z)
z - the z to setpublic boolean isAdjustWidth()
adjustWidthpublic void setAdjustWidth(boolean adjustWidth)
adjustWidth - the adjustWidth to setpublic boolean isAdjustHeight()
adjustHeightpublic void setAdjustHeight(boolean adjustHeight)
adjustHeight - the adjustHeight to setpublic void setAdjustSize(boolean adjustSize)
adjustSize - the adjustWidth and adjustHeight to setpublic boolean isUseOriginX()
useOriginXpublic void setUseOriginX(boolean useOriginX)
useOriginX - the useOriginX to setpublic boolean isUseOriginY()
useOriginYpublic void setUseOriginY(boolean useOriginY)
useOriginY - the useOriginY to setpublic void setUseOrigin(boolean useOrigin)
useOrigin - the useOriginX and useOriginY to setpublic void setWidth(float width)
Sprite.setSize(float, float)public void setHeight(float height)
Sprite.setSize(float, float)public static java.util.Comparator<Box2DSprite> getZComparator()
zComparatorpublic static void setZComparator(java.util.Comparator<Box2DSprite> zComparator)
zComparator - the zComparator to setpublic static net.dermetfan.utils.Accessor<Box2DSprite,?> getUserDataAccessor()
userDataAccessorpublic static void setUserDataAccessor(net.dermetfan.utils.Accessor<Box2DSprite,java.lang.Object> userDataAccessor)
userDataAccessor - the userDataAccessor to set