hx3d  1
2D/3D Simple Game Framework
Public Member Functions | List of all members
hx3d::graphics::Sprite Class Reference

2D texture manipulation. More...

#include <sprite.hpp>

Public Member Functions

 Sprite ()
 Create a sprite without texture. More...
 
void setTexture (const Ptr< Texture > &texture)
 Set the sprite texture. More...
 
void setTexture (Framebuffer &buffer)
 Set the sprite texture from a framebuffer color buffer. More...
 
void setTexture (TextureRegion &region)
 Set the sprite texture from a texture region. More...
 
Ptr< TexturegetTexture ()
 Get the sprite texture. More...
 
void scaleTexture ()
 Scale the texture coordinates following the texture size.
 
virtual void draw (Ptr< Shader > shader) override
 Draw the mesh using a shader. More...
 
- Public Member Functions inherited from hx3d::graphics::Mesh
void setTint (Color tint)
 Set the mesh tint. More...
 
ColorgetTint ()
 Get the mesh tint. More...
 
void updateColor ()
 Update the mesh color from the tint.
 
void setGeometry (Ptr< geom::BaseGeometry > geometry)
 Set the mesh geometry. More...
 
Ptr< geom::BaseGeometry > & getGeometry ()
 Get the mesh geometry. More...
 

Additional Inherited Members

- Public Attributes inherited from hx3d::graphics::Mesh
Transform transform
 Mesh transformation.
 
- Protected Attributes inherited from hx3d::graphics::Mesh
Color _tint
 Tint color.
 
Ptr< geom::BaseGeometry_geometry
 Current geometry.
 

Detailed Description

2D texture manipulation.

Example code

// Inside a create function...
Sprite sprite;
// Load the texture "my_texture"
sprite.setTexture(Core::Assets()->get<Texture>("my_texture"));
// Set the sprite coordinate to (5, 5)
sprite.transform.position.x = 5;
sprite.transform.position.y = 5;
[...]
// Inside a render function...
batch.begin();
// Draw the sprite
batch.draw(sprite);
batch.end();

Definition at line 62 of file sprite.hpp.

Constructor & Destructor Documentation

hx3d::graphics::Sprite::Sprite ( )

Create a sprite without texture.

You must set it after with setTexture.

Definition at line 28 of file sprite.cpp.

Member Function Documentation

void hx3d::graphics::Sprite::draw ( Ptr< Shader shader)
overridevirtual

Draw the mesh using a shader.

Parameters
shaderShader (Ptr)

Reimplemented from hx3d::graphics::Mesh.

Definition at line 94 of file sprite.cpp.

Ptr< Texture > hx3d::graphics::Sprite::getTexture ( )

Get the sprite texture.

Returns
Texture (Ptr)

Definition at line 74 of file sprite.cpp.

void hx3d::graphics::Sprite::setTexture ( const Ptr< Texture > &  texture)

Set the sprite texture.

Parameters
textureTexture (Ptr)

Definition at line 36 of file sprite.cpp.

void hx3d::graphics::Sprite::setTexture ( Framebuffer buffer)

Set the sprite texture from a framebuffer color buffer.

Parameters
bufferFramebuffer

Definition at line 49 of file sprite.cpp.

void hx3d::graphics::Sprite::setTexture ( TextureRegion region)

Set the sprite texture from a texture region.

Parameters
regionTextureRegion

Definition at line 62 of file sprite.cpp.


The documentation for this class was generated from the following files: