本文整理汇总了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;
}