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


C# Graphics.Texture2D類代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.Texture2D的典型用法代碼示例。如果您正苦於以下問題:C# Texture2D類的具體用法?C# Texture2D怎麽用?C# Texture2D使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Texture2D類屬於Microsoft.Xna.Framework.Graphics命名空間,在下文中一共展示了Texture2D類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: NPC

 public NPC(Texture2D texture, Dictionary<AnimationKey, Animation> animations, IEContentManager content)
     : base(texture, animations)
 {
     speakingRadius = 80f;
     dialog = new DialogComponent(content);
     dialog.Hide();
 }
開發者ID:tojuhaka,項目名稱:HakaGame,代碼行數:7,代碼來源:NPC.cs

示例2: ObjectClass

 public ObjectClass(Texture2D Img)
 {
     Image = Img;
     Position = Vector2.Zero;
     Center = Vector2.Zero;
     Rotation = 0.0f;
 }
開發者ID:lionell,項目名稱:winnie_the_pooh_game,代碼行數:7,代碼來源:Object.cs

示例3: Octopus

 public Octopus(Texture2D textura, Vector2 posicion)
 {
     Textura = textura;
     Posicion = posicion;
     Inicializa_Cuadros();
     iniAreas();
 }
開發者ID:CMarth,項目名稱:BalloonAdventure,代碼行數:7,代碼來源:Octopus.cs

示例4: Toolbar

 public Toolbar(Texture2D texture, SpriteFont font, Vector2 position)
 {
     _texture = texture;
     _font = font;
     _position = position;
     _textPosition=new Vector2(130,_position.Y+10);
 }
開發者ID:hover024,項目名稱:Virus-Attack,代碼行數:7,代碼來源:Toolbar.cs

示例5: GetTexture

        public Texture2D GetTexture(string name)
        {
            if (!_initialized)
                Initialize();

            if (_textures.ContainsKey(name))
                return _textures[name];
            else
            {
                Rectangle r = RectangleFromName(name);

                if (r.Width > 1)
                {
                    Color[] colors = new Color[_width * _height];

                    _texture.GetData<Color>(0, r, colors, 0, _width * _height);

                    Texture2D tex = new Texture2D(MainApplication.Instance.GraphicsDevice, _width, _height);

                    tex.SetData<Color>(0, new Rectangle(0, 0, _width, _height), colors, 0, _width * _height);

                    _textures.Add(name, tex);

                    return tex;
                }

                return null;
            }
        }
開發者ID:mrommel,項目名稱:MiRo.SimHexWorld,代碼行數:29,代碼來源:TextureAtlas.cs

示例6: Initialize

 public override void Initialize(Texture2D initTexture, Vector2 initPosition)
 {
     base.Initialize(initTexture, initPosition);
     acceleration = 2;
     velocity = 0;
     onTopOfBlock = false;
 }
開發者ID:dylanPowers,項目名稱:CS122-PA8,代碼行數:7,代碼來源:Player.cs

示例7: Player

        /// <summary>
        /// Player constructor.
        /// </summary>
        /// <param name="color"></param>
        public Player(Alliance alliance, Color color, Point startLocation)
        {
            Game1.GetInstance().players.AddLast(this);
            this.device = Game1.GetInstance().GraphicsDevice;
            this.alliance = alliance;
            this.startLocation = startLocation;
            if (!this.alliance.members.Contains(this)) this.alliance.members.AddLast(this);
            this.color = color;

            selectionTex = Game1.GetInstance().Content.Load<Texture2D>("Selection");
            selectedTex = Game1.GetInstance().Content.Load<Texture2D>("Selected");

            units = new CustomArrayList<Unit>();
            buildings = new CustomArrayList<Building>();
            hud = new HUD(this, color);
            resources = 100000;

            meleeStore = new MeleeStore(this);
            rangedStore = new RangedStore(this);
            fastStore = new FastStore(this);

            arrowManager = new ArrowManager();

            lightTexture = Game1.GetInstance().Content.Load<Texture2D>("Fog/Light");

            MouseManager.GetInstance().mouseClickedListeners += ((MouseClickListener)this).OnMouseClick;
            MouseManager.GetInstance().mouseReleasedListeners += ((MouseClickListener)this).OnMouseRelease;
            MouseManager.GetInstance().mouseMotionListeners += ((MouseMotionListener)this).OnMouseMotion;
            MouseManager.GetInstance().mouseDragListeners += ((MouseMotionListener)this).OnMouseDrag;
        }
開發者ID:Wotuu,項目名稱:RTS_XNA_v2,代碼行數:34,代碼來源:Player.cs

示例8: LoadContent

        public void LoadContent(ContentManager content, GraphicsDeviceManager graphicsDeviceManager)
        {
            texture = content.Load<Texture2D>("brick_texture_map");

            wall = new VertexPositionTexture[22];
            wall[0] = new VertexPositionTexture(new Vector3(200, 0, 200), new Vector2(0, 0));
            wall[1] = new VertexPositionTexture(new Vector3(200, 200, 200), new Vector2(2, 0));
            wall[2] = new VertexPositionTexture(new Vector3(0, 0, 200), new Vector2(0, 2));
            wall[3] = new VertexPositionTexture(new Vector3(0, 200, 200), new Vector2(2, 2));
            wall[4] = new VertexPositionTexture(new Vector3(0, 0, 220), new Vector2(0, 0));
            wall[5] = new VertexPositionTexture(new Vector3(0, 200, 220), new Vector2(2, 0));
            wall[6] = new VertexPositionTexture(new Vector3(200, 0, 220), new Vector2(0, 2));
            wall[7] = new VertexPositionTexture(new Vector3(200, 200, 220), new Vector2(2, 2));
            wall[8] = new VertexPositionTexture(new Vector3(200, 0, 200), new Vector2(0, 0));
            wall[9] = new VertexPositionTexture(new Vector3(200, 200, 220), new Vector2(2, 0));
            wall[10] = new VertexPositionTexture(new Vector3(200, 200, 200), new Vector2(2, 2));
            wall[11] = new VertexPositionTexture(new Vector3(0, 200, 220), new Vector2(0, 2));
            wall[12] = new VertexPositionTexture(new Vector3(0, 200, 200), new Vector2(0, 0));

            // Set vertex data in VertexBuffer
            vertexBuffer = new VertexBuffer(graphicsDeviceManager.GraphicsDevice, typeof(VertexPositionTexture), wall.Length, BufferUsage.None);
            vertexBuffer.SetData(wall);

            // Initialize the BasicEffect
            effect = new BasicEffect(graphicsDeviceManager.GraphicsDevice);
        }
開發者ID:Woodje,項目名稱:3DGame,代碼行數:26,代碼來源:Wall.cs

示例9: WaterSubMesh

 public WaterSubMesh(Mesh mesh, RenderTarget2D reflectionBuffer, RenderTarget2D refractionBuffer, Texture2D offsetMap, Texture2D normalMap) : base(mesh)
 {
     m_ReflectionTarget = reflectionBuffer;
     m_RefractionTarget = refractionBuffer;
     m_OffsetMap = offsetMap;
     m_NormalMap = normalMap;
 }
開發者ID:Imortilize,項目名稱:Psynergy-Engine,代碼行數:7,代碼來源:WaterSubMesh.cs

示例10: MapTile

        public MapTile(Texture2D texture, int type, int x, int y, int size)
        {
            this.TileTexture = texture;

            // Changes which column of the sprite sheet the game uses to draw
            int blockX = size * SpriteSheetXOffset;
            this.TileColour = Color.White;
            switch (type)
            {
                case 0: break;
                case 1: this.RectSlice = new Rectangle(blockX, size * 1, size, size); this.IsSolid = true; break;
                case 2: this.RectSlice = new Rectangle(blockX, size * 2, size, size); this.IsSolid = true; this.IsSpring = true; break;
                case 3: this.RectSlice = new Rectangle(blockX, size * 3, size, size); this.IsSolid = true; break;
                case 4: this.RectSlice = new Rectangle(blockX, size * 4, size, size); this.IsSolid = true; break;
                case 5: this.RectSlice = new Rectangle(blockX, size * 5, size, size); this.IsSolid = true; break;
                case 6: this.RectSlice = new Rectangle(blockX, size * 6, size, size); this.IsSolid = true; break;
                case 7:
                    this.RectSlice = new Rectangle(blockX, size * 7, size, size); this.IsSolid = false;
                    this.TileColour = new Color(255, 255, 255, 20);
                    this.IsWater = true;
                    break;
                default: this.RectSlice = new Rectangle(blockX, size * 0, size, size); this.IsSolid = true; break;
            }
            this.Width = size;
            this.Height = size;
            this.PositionRect = new Rectangle(x, y, this.Width, this.Height);
        }
開發者ID:colincapurso,項目名稱:Game-Engine-XNA,代碼行數:27,代碼來源:MapTile.cs

示例11: debugDraw

 public void debugDraw(SpriteBatch spritebatch, Texture2D texture)
 {
     foreach (Node nod in nodes){
         Vector2 adjustedPos = new Vector2(nod.Position.X - texture.Width/2, nod.Position.Y - texture.Height/2);
         spritebatch.Draw (texture, adjustedPos, Color.White);
     }
 }
開發者ID:fordream,項目名稱:Octo-concurrency,代碼行數:7,代碼來源:PathFinder.cs

示例12: Emitter

 public Emitter(Vector2 position, Texture2D sprite, Color color, int size)
 {
     this.position = position;
     this.sprite = sprite;
     this.color = color;
     this.size = size;
 }
開發者ID:Daniel-Nichol,項目名稱:ox-g1-surface,代碼行數:7,代碼來源:Emitter.cs

示例13: APNGFrame

        internal APNGFrame(GraphicsDevice graphicsDevice, Frame frame)
        {
            if (frame.fcTLChunk != null)
            {
                X = (int) frame.fcTLChunk.XOffset;
                Y = (int) frame.fcTLChunk.YOffset;
                Width = (int) frame.fcTLChunk.Width;
                Height = (int) frame.fcTLChunk.Height;
                BlendOp = frame.fcTLChunk.BlendOp;
                DisposeOp = frame.fcTLChunk.DisposeOp;
                DelayTime = new TimeSpan(
                    TimeSpan.TicksPerSecond*frame.fcTLChunk.DelayNum/frame.fcTLChunk.DelayDen);
            }
            else
            {
                X = 0;
                Y = 0;
                Width = frame.IHDRChunk.Width;
                Height = frame.IHDRChunk.Height;
                BlendOp = BlendOps.APNGBlendOpSource;
                DisposeOp = DisposeOps.APNGDisposeOpNone;
                DelayTime = TimeSpan.Zero;
            }

            // frame.GetStream() is not seekable, so we build a new MemoryStream.
            FrameTexture = Texture2D.FromStream(
                graphicsDevice, new MemoryStream(frame.GetStream().ToArray()));
            MultiplyAlpha(FrameTexture);
        }
開發者ID:xupefei,項目名稱:EAGSS,代碼行數:29,代碼來源:APNGFrame.cs

示例14: DrawSpriteGlyph

        internal void DrawSpriteGlyph(Texture2D texture, Vector4 dest, Vector4 source, Color color)
        {
            if (!m_DrawString_InProgress)
                Logging.Fatal("BeginDrawString() must be called before DrawSpriteGlyph()");

            Vector4 uv = new Vector4(
                (float)source.X / texture.Width,
                (float)source.Y / texture.Height,
                (float)(source.X + source.Z) / texture.Width,
                (float)(source.Y + source.W) / texture.Height);

            VertexPositionTextureHueExtra[] v = new VertexPositionTextureHueExtra[4]
            {
                new VertexPositionTextureHueExtra(new Vector3(dest.X, dest.Y, m_DrawString_Depth), new Vector2(uv.X, uv.Y), color, Vector4.Zero), // top left
                new VertexPositionTextureHueExtra(new Vector3(dest.X + dest.Z, dest.Y, m_DrawString_Depth), new Vector2(uv.Z, uv.Y), color, Vector4.Zero), // top right
                new VertexPositionTextureHueExtra(new Vector3(dest.X, dest.Y + dest.W, m_DrawString_Depth), new Vector2(uv.X, uv.W), color, Vector4.Zero), // bottom left
                new VertexPositionTextureHueExtra(new Vector3(dest.X + dest.Z, dest.Y + dest.W, m_DrawString_Depth), new Vector2(uv.Z, uv.W), color, Vector4.Zero) // bottom right
            };

            /*if (shadow != null)
            {
                Color shadow2 = new Color(
                    shadow.Value.R, shadow.Value.G,
                    shadow.Value.B, 128);
                for (int i = 0; i < 4; i++)
                {
                    VertexPositionTextureHueExtra v0 = v[i];
                    v0.Hue = shadow.Value;
                    v0.Position.Y += 1f;
                    m_DrawString_VertexList.Add(v0);
                }
            }*/
            for (int i = 0; i < 4; i++)
                m_DrawString_VertexList.Add(v[i]);
        }
開發者ID:FreeReign,項目名稱:UltimaXNA,代碼行數:35,代碼來源:YSpriteBatch_DrawString.cs

示例15: RenderPolygone

 public static void RenderPolygone(SpriteBatch spriteBatch, Texture2D texture, Polygon polygon, int lineThickness, Color color)
 {
     for (int i = 0; i < polygon.Points.Count; ++i)
     {
         RenderLine(spriteBatch, texture, polygon.Points[i], polygon.Edges[i], 1, lineThickness, color);
     }
 }
開發者ID:Norskan,項目名稱:Playground,代碼行數:7,代碼來源:RenderUtil.cs


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