com.annahid.libs.artenus.graphics.sprites
GridSprite
Provides a grid of texture blocks. It is intended for platform or map based games. You can create a large grid and add it to the scene as a normal sprite. Only the portion of the grid that is visible will be rendered. Use this sprite for level maps.
Note that this class is subject to revision or removal in the future. It is NOT yet deprecated. Support for platform-based games is currently being revised and a faster and more robust framework will be introduced in future versions.
public final class GridSprite extends SpriteEntity
Field Summary
Fields inherited from com.annahid.libs.artenus.graphics.sprites.SpriteEntity
Constructor Summary
Modifier and Type | Constructor and Description |
---|---|
public | GridSprite(int resourceId, float frameWidth, float frameHeight, float margin, int cols, int rows) Creates a GridSprite using a image resource id and block parameters. |
Method Summary
Modifier and Type | Method and Description |
---|---|
public float | getAlpha(int col, int row) Gets the transparency value for the given grid block. |
public int | getColumns() Gets the number of columns for this grid. |
public int | getFrame(int col, int row) Gets the current frame (image block index) of the given grid block. |
public float | getHeight() Gets the assigned height for this grid. |
public int | getRows() Gets the number of rows for this grid. |
public float | getWidth() Gets the assigned width for this grid. |
public void | render(RenderingContext context, int flags) Renders the visual content. |
public void | setAlpha(int col, int row, float alpha) Sets the transparency value of the given grid block. |
public void | setFrame(int col, int row, int frame) Sets the current frame of the given grid block. |
public void | setVisibleRegion(float startX, float startY, float endX, float endY) Sets the visible area within the grid block. |
Methods inherited from com.annahid.libs.artenus.graphics.sprites.SpriteEntity
advance
, getAlpha
, getAnimation
, getColorFilter
, getPosition
, getRotation
, getScale
, hasBehavior
, move
, onAttach
, onDetach
, rotate
, setAlpha
, setAnimation
, setColorFilter
, setColorFilter
, setPosition
, setPosition
, setRotation
, setScale
, setScale
Methods inherited from java.lang.Object
clone
, equals
, finalize
, getClass
, hashCode
, notify
, notifyAll
, toString
, wait
, wait
, wait
Constructor Detail
GridSprite | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
public GridSprite( int resourceId, float frameWidth, float frameHeight, float margin, int cols, int rows )Creates a GridSprite using a image resource id and block parameters. Like Sprite, this class supports SVG images with raw resource type as well as images normally supported by the android platform. It is recommended to provide SVG images for better scaling in different screen resolutions. The image is cut out into frames using the given block width and height. Parameters:
|
Method Detail
getAlpha | ||||
---|---|---|---|---|
public float getAlpha( int col, int row ) Gets the transparency value for the given grid block. Parameters:
Returns:
The transparency (alpha) value |
getColumns |
---|
public int getColumns() Gets the number of columns for this grid. Returns:
The number of columns |
getFrame | ||||
---|---|---|---|---|
public int getFrame( int col, int row ) Gets the current frame (image block index) of the given grid block. To
understand image frames, see the documentation for Sprite. Parameters:
Returns:
The current frame See Also:
|
getHeight |
---|
public float getHeight() Gets the assigned height for this grid. Returns:
The height of the grid in pixels |
getRows |
---|
public int getRows() Gets the number of rows for this grid. Returns:
The number of rows |
getWidth |
---|
public float getWidth() Gets the assigned width for this grid. Returns:
The width of the grid in pixels |
render |
---|
public void render( RenderingContext context, int flags ) Renders the visual content. |
setAlpha | ||||||
---|---|---|---|---|---|---|
public void setAlpha( int col, int row, float alpha ) Sets the transparency value of the given grid block. Parameters:
|
setFrame | ||||||
---|---|---|---|---|---|---|
public void setFrame( int col, int row, int frame ) Sets the current frame of the given grid block. To understand image frames,
see the documentation for Sprite. Parameters:
See Also:
|
setVisibleRegion | ||||||||
---|---|---|---|---|---|---|---|---|
public void setVisibleRegion( float startX, float startY, float endX, float endY ) Sets the visible area within the grid block. The renderer will not render anything that lies
outside the rectangular are specified. Use this method to achieve better performance. Note
that there is no guarantee that the contents are clipped by the given area. Parameters:
|