本文整理汇总了C++中Tileset::getSpriteSheet方法的典型用法代码示例。如果您正苦于以下问题:C++ Tileset::getSpriteSheet方法的具体用法?C++ Tileset::getSpriteSheet怎么用?C++ Tileset::getSpriteSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tileset
的用法示例。
在下文中一共展示了Tileset::getSpriteSheet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Renderer_renderTile
void Renderer_renderTile(TileComponent* tileComponent, Layer* layer)
{
if (tileComponent->getTileset() != 0)
{
GameObject* gameObject = tileComponent->getGameObject();
vec2 position = layer->getMap()->tileToDeviceCoordinates(gameObject->getPosition().x, gameObject->getPosition().y);
tileComponent->getSprite()->setDepth(layer->getDepth());
tileComponent->getSprite()->setOpacity(layer->getOpacity());
Tileset* tileset = tileComponent->getTileset();
Sprite::PixelClip clip = tileset->getSpriteSheet()->getClip(tileComponent->getTileId());
Texture* tex = tileset->getSpriteSheet()->getTexture();
tileComponent->getSprite()->setClip(float(tex->getWidth()), float(tex->getHeight()), clip);
vec2 scale(1.0f);
if (tileComponent->isFlippedHorizontally())
{
scale.x *= -1.0f;
}
if (tileComponent->isFlippedVertically())
{
scale.y *= -1.0f;
}
vec2 p = position;
//p.x += clip.clipSize.x*0.5f;
p.y += clip.clipSize.y*0.5f;
p.x += layer->getMap()->getTileWidth();// *0.5f;
// p.x -= 1.5f;
p.y -= layer->getMap()->getTileHeight();// *0.5f;
p.x -= tileset->getTileOffsetX();
p.y -= tileset->getTileOffsetY();
p.y += layer->getMap()->getTileWidth() * 0.5f;
p.x -= layer->getMap()->getTileWidth() * 1.0f;
if (gameObject->getName() == "Ball")
{
int i = 0;
i;
}
layer->getBatch()->addSprite(tex, tileComponent->getSprite(), p, gameObject->getRotation(), scale, vec2(0,0));
}
}
示例2: render
void Tile::render(Layer* layer)
{
if( getTileset() != 0 )
{
vec2 position = layer->getMap()->tileToDeviceCoordinates(getPosition().x,getPosition().y);
m_sprite->setDepth( layer->getDepth() );
m_sprite->setOpacity( layer->getOpacity() );
Tileset* tileset = getTileset();
Sprite::PixelClip clip = tileset->getSpriteSheet()->getClip(getTileId());
Texture* tex = tileset->getSpriteSheet()->getTexture();
m_sprite->setClip(float(tex->getWidth()), float(tex->getHeight()), clip);
vec2 scale(1.0f);
if( isFlippedHorizontally() )
{
scale.x *= -1.0f;
}
if( isFlippedVertically() )
{
scale.y *= -1.0f;
}
vec2 p = position;
p.x += clip.clipSize.x*0.5f;
p.y += clip.clipSize.y*0.5f;
p.x -= layer->getMap()->getTileWidth()*0.5f;
p.y -= layer->getMap()->getTileHeight()*0.5f;
p.x -= tileset->getTileOffsetX();
p.y -= tileset->getTileOffsetY();
vec2 offset(0.0f);
layer->getBatch()->addSprite( tex, m_sprite, p, 0, scale );
}
}