當前位置: 首頁>>代碼示例>>C#>>正文


C# Texture2D.ToString方法代碼示例

本文整理匯總了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;
        }
開發者ID:IndrekV,項目名稱:MonoFlixel,代碼行數:52,代碼來源:FlxG.cs

示例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");
        }
開發者ID:DragonKnightRose,項目名稱:CyberPunkd,代碼行數:77,代碼來源:Game1.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Texture2D.ToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。