本文整理匯總了C#中Camera2D.ToVirtual方法的典型用法代碼示例。如果您正苦於以下問題:C# Camera2D.ToVirtual方法的具體用法?C# Camera2D.ToVirtual怎麽用?C# Camera2D.ToVirtual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Camera2D
的用法示例。
在下文中一共展示了Camera2D.ToVirtual方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DrawLevel
public string DrawLevel(SpriteBatch sb, Camera2D camera, ScreenInfo screenInfo)
{
if (sb == null)
return "Level.DrawLevel - Error: Null SpriteBatch\n";
Vector2 topLeft = camera.ToVirtual(Vector2.Zero, false);
Vector2 bottomRight = camera.ToVirtual(screenInfo.screenDimensions, false);
uint numColumns, numRows;
int curTileWidth = 0, curTileHeight = 0;
for (int i = 0; i < numBackgroundLayers; ++i)
{
numColumns = backgroundRowTiles[i];
numRows = backgroundRowColumns[i];
if(numColumns > 0 && numRows > 0)
{
curTileWidth = backgrounds[i][0][0].getTileWidth();
curTileHeight = backgrounds[i][0][0].getTileHeight();
}
// TODO don't run through the tiles not near the screen
for (uint x = 0; x < numColumns; ++x)
{
for (uint y = 0; y < numRows; ++y)
{
if ((((x + 1) * curTileWidth) < topLeft.X || (x * curTileWidth) > bottomRight.X) &&
(((y + 1) * curTileHeight) < topLeft.Y || (y * curTileHeight) > bottomRight.Y))
continue;
sb.Draw(backgrounds[i][x][y].getTexture(), new Vector2(x * curTileWidth, y * curTileHeight));
}
}
}
//testObj.SetPosition(new Vector2(bottomRight.X - 100, bottomRight.Y - 100));
//testObj.SetPosition(new Vector2(topLeft.X, topLeft.Y));
//testObj.Draw(sb, camera, curScreenPos, curScreenDimensions, pxWidth, pxHeight);
return null;
}