本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Texture2D.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.ToString方法的具体用法?C# Texture2D.ToString怎么用?C# Texture2D.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.Texture2D
的用法示例。
在下文中一共展示了Texture2D.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addBitmap
/// <summary>
/// Loads a bitmap from a file, caches it, and generates a horizontally flipped version if necessary.
/// </summary>
/// <param name="graphic">The image file that you want to load.</param>
/// <param name="reverse">Whether to generate a flipped version.</param>
/// <param name="unique">Ensures that the bitmap data uses a new slot in the cache.</param>
/// <param name="key">Force the cache to use a specific Key to index the bitmap.</param>
/// <returns>The <code>BitmapData</code> we just created.</returns>
public static Texture2D addBitmap(Texture2D graphic, bool reverse = false, bool unique = false, string key = null)
{
bool needReverse = false;
if(key == null)
{
key = graphic.ToString()+(reverse?"_REVERSE_":"");
if(unique && checkBitmapCache(key))
{
int inc = 0;
string ukey;
do
{
ukey = key + inc++;
} while(checkBitmapCache(ukey));
key = ukey;
}
}
//If there is no data for this key, generate the requested graphic
if(!checkBitmapCache(key))
{
//_cache[key] = graphic.bitmapData;
if(reverse)
needReverse = true;
}
//BitmapData pixels = _cache[key];
Texture2D pixels = graphic;
if(!needReverse && reverse && (pixels.Width == graphic.Width))
needReverse = true;
if(needReverse)
{
/*
BitmapData newPixels = new BitmapData(pixels.Width<<1,pixels.Height,true,0x00000000);
newPixels.draw(pixels);
Matrix mtx = new Matrix();
mtx.scale(-1,1);
mtx.translate(newPixels.width,0);
newPixels.draw(pixels,mtx);
pixels = newPixels;
_cache[Key] = pixels;
*/
}
return pixels;
}
示例2: LoadContent
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
Drawable.setSpriteBatch(spriteBatch);
wallSpriteMap = Content.Load<Texture2D>(@"SpriteSheets\Walls");
shootableWallSpriteMap = Content.Load<Texture2D>(@"SpriteSheets\Walls_Shootable");
bathroomDoorSpriteMap = Content.Load<Texture2D>(@"SpriteSheets\Wall_bathroom");
normalDoorSpriteMap = Content.Load<Texture2D>(@"SpriteSheets\Walls_locked");
keycardDoorSpriteMap = Content.Load<Texture2D>(@"SpriteSheets\Walls_keycard");
generalSecuritySpriteMap = Content.Load<Texture2D>(@"SpriteSheets\Security_Generic_sheet");
securityHeadSpriteMap = Content.Load<Texture2D>(@"SpriteSheets\Security_head_sheet");
player = new Player(Content.Load<Texture2D>(@"SpriteSheets\Female_sheet"), tickTime);
tile = new Floor(Content.Load<Texture2D>(@"SpriteSheets\floor"));
//tile = new Floor(Content.Load<Texture2D>(@"SpriteSheets\Wall_bathroom"));
//tile = new Floor(bathroomDoorSpriteMap);
// TODO: use this.Content to load your game content here
//load sprite maps
Console.WriteLine("shootable set: "+shootableWallSpriteMap.ToString());
Console.WriteLine("regular set: "+wallSpriteMap.ToString());
//load tilesets
tileTable = new Tile[22];
tileTable[FLOOR_TILE] = tile;
tileTable[WALL_LEFT_TILE] = new Wall(wallSpriteMap);
tileTable[WALL_LEFT_TILE].setSpriteFrame(new Point(0,0));
tileTable[WALL_TOP_TILE] = new Wall(wallSpriteMap);
tileTable[WALL_TOP_TILE].setSpriteFrame(new Point(1, 0));
tileTable[WALL_BOTTOM_TILE] = new Wall(wallSpriteMap);
tileTable[WALL_BOTTOM_TILE].setSpriteFrame(new Point(2, 0));
tileTable[WALL_RIGHT_TILE] = new Wall(wallSpriteMap);
tileTable[WALL_RIGHT_TILE].setSpriteFrame(new Point(3, 0));
tileTable[WALL_LL_TILE] = new Wall(wallSpriteMap);
tileTable[WALL_LL_TILE].setSpriteFrame(new Point(0, 1));
tileTable[WALL_UL_TILE] = new Wall(wallSpriteMap);
tileTable[WALL_UL_TILE].setSpriteFrame(new Point(1, 1));
tileTable[WALL_UR_TILE] = new Wall(wallSpriteMap);
tileTable[WALL_UR_TILE].setSpriteFrame(new Point(2, 1));
tileTable[WALL_LR_TILE] = new Wall(wallSpriteMap);
tileTable[WALL_LR_TILE].setSpriteFrame(new Point(3, 1));
tileTable[WALL_LL_CORNER] = new Wall(wallSpriteMap);
tileTable[WALL_LL_CORNER].setSpriteFrame(new Point(0, 2));
tileTable[WALL_UL_CORNER] = new Wall(wallSpriteMap);
tileTable[WALL_UL_CORNER].setSpriteFrame(new Point(1, 2));
tileTable[WALL_UR_CORNER] = new Wall(wallSpriteMap);
tileTable[WALL_UR_CORNER].setSpriteFrame(new Point(2, 2));
tileTable[WALL_LR_CORNER] = new Wall(wallSpriteMap);
tileTable[WALL_LR_CORNER].setSpriteFrame(new Point(3, 2));
tileTable[WALL_SHOOTABLE_UPPER] = new Wall(shootableWallSpriteMap);
tileTable[WALL_SHOOTABLE_UPPER].setSpriteFrame(new Point(2, 0));
//load map files
viewCorner = new[] {0, 0};
LoadMap("tutorial");
}