Sprite Flipping & Texture Offsets
This commit is contained in:
@ -55,7 +55,7 @@ namespace ia::iae::rpg
|
||||
|
||||
VOID OnUpdate(IN FLOAT32 deltaTime)
|
||||
{
|
||||
IAEngine::DrawSprite(g_playerSpriteSheet, 0, 0, {100.0f, 100.0f});
|
||||
IAEngine::DrawSprite(g_playerSpriteSheet, 2, 0, {100.0f, 100.0f}, {1.0f, 1.0f}, 0.0f);
|
||||
}
|
||||
|
||||
VOID OnResize(IN INT32 newWidth, IN INT32 newHeight)
|
||||
|
||||
@ -288,6 +288,6 @@ namespace ia::iae
|
||||
IN Vec2 scale, IN FLOAT32 rotation, IN BOOL flipH, IN BOOL flipV, IN Vec2 uvOffset)
|
||||
{
|
||||
const auto t = static_cast<Resource_SpriteSheet*>(g_resources[spriteSheet]);
|
||||
Renderer::DrawDynamicSpriteTopLeft(t->Texture, animationIndex, frameIndex, position, scale, rotation, flipH, flipV, uvOffset);
|
||||
Renderer::DrawDynamicSpriteTopLeft(t->Texture, frameIndex, animationIndex, position, scale, rotation, flipH, flipV, uvOffset);
|
||||
}
|
||||
} // namespace ia::iae
|
||||
@ -356,10 +356,21 @@ namespace ia::iae
|
||||
{
|
||||
const auto &d = g_texureData[texture];
|
||||
const auto &t = g_activeTextureAtlasUVMap[texture];
|
||||
const auto pX = (tileIndexX * ((FLOAT32) d.TileWidth)) * g_activeTextureAtlasInverseSize.x;
|
||||
const auto pY = (tileIndexY * ((FLOAT32) d.TileHeight)) * g_activeTextureAtlasInverseSize.y;
|
||||
return Vec4(t.x + pX, t.y + pY, d.TileWidth * g_activeTextureAtlasInverseSize.x,
|
||||
const auto pX = ((tileIndexX + uvOffset.x) * ((FLOAT32) d.TileWidth)) * g_activeTextureAtlasInverseSize.x;
|
||||
const auto pY = ((tileIndexY + uvOffset.y) * ((FLOAT32) d.TileHeight)) * g_activeTextureAtlasInverseSize.y;
|
||||
auto texCoords = Vec4(t.x + pX, t.y + pY, d.TileWidth * g_activeTextureAtlasInverseSize.x,
|
||||
d.TileHeight * g_activeTextureAtlasInverseSize.y);
|
||||
if(flipH)
|
||||
{
|
||||
texCoords.x += texCoords.z;
|
||||
texCoords.z *= -1;
|
||||
}
|
||||
if(flipV)
|
||||
{
|
||||
texCoords.y += texCoords.w;
|
||||
texCoords.w *= -1;
|
||||
}
|
||||
return texCoords;
|
||||
}
|
||||
} // namespace ia::iae
|
||||
|
||||
|
||||
Reference in New Issue
Block a user