本文整理汇总了C++中SpriteSheet::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ SpriteSheet::Draw方法的具体用法?C++ SpriteSheet::Draw怎么用?C++ SpriteSheet::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpriteSheet
的用法示例。
在下文中一共展示了SpriteSheet::Draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawSprite
void DrawSprite ( const std::string& sheetname, int sheet_x, int sheet_y, vec2 position, vec2 size, float rotation, colour col )
{
SetShader("Sprite");
EnableTexturing();
EnableBlending();
ClearColour();
SetColour(col);
SpriteSheet* sheet;
SheetMap::iterator iter = spriteSheets.find(sheetname);
if (iter == spriteSheets.end())
{
// load it
sheet = new SpriteSheet(sheetname);
spriteSheets[sheetname] = sheet;
}
else
{
sheet = iter->second;
}
Matrices::SetViewMatrix(matrix2x3::Translate(position));
Matrices::SetModelMatrix(matrix2x3::Identity());
if (sheet->IsRotational())
{
assert(sheet_x == 0);
assert(sheet_y == 0);
sheet->DrawRotation(size, rotation);
}
else
{
glRotatef(RAD2DEG(rotation), 0.0f, 0.0f, 1.0f);
sheet->Draw(sheet_x, sheet_y, size);
}
}
示例2: DrawSpriteFrame
void DrawSpriteFrame ( const std::string& sheetname, vec2 position, vec2 size, int index, float rotation, colour col )
{
SetShader("Sprite");
EnableTexturing();
EnableBlending();
ClearColour();
SetColour(col);
SpriteSheet* sheet;
SheetMap::iterator iter = spriteSheets.find(sheetname);
if (iter == spriteSheets.end())
{
sheet = new SpriteSheet(sheetname);
spriteSheets[sheetname] = sheet;
}
else
{
sheet = iter->second;
}
Matrices::SetViewMatrix(matrix2x3::Translate(position));
Matrices::SetModelMatrix(matrix2x3::Identity());
glRotatef(RAD2DEG(rotation), 0.0f, 0.0f, 1.0f);
int x = index % sheet->SheetTilesX();
int y = (index - x) / sheet->SheetTilesX();
sheet->Draw(x, y, size);
}
示例3: Draw
void Entity::Draw(ShaderProgram* program, Matrix& gameMatrix, SpriteSheet& sprite) {
sprite.Draw(program, gameMatrix, x, y);
}