当前位置: 首页>>代码示例>>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;未经允许,请勿转载。