本文整理汇总了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();
}
示例2: ObjectClass
public ObjectClass(Texture2D Img)
{
Image = Img;
Position = Vector2.Zero;
Center = Vector2.Zero;
Rotation = 0.0f;
}
示例3: Octopus
public Octopus(Texture2D textura, Vector2 posicion)
{
Textura = textura;
Posicion = posicion;
Inicializa_Cuadros();
iniAreas();
}
示例4: Toolbar
public Toolbar(Texture2D texture, SpriteFont font, Vector2 position)
{
_texture = texture;
_font = font;
_position = position;
_textPosition=new Vector2(130,_position.Y+10);
}
示例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;
}
}
示例6: Initialize
public override void Initialize(Texture2D initTexture, Vector2 initPosition)
{
base.Initialize(initTexture, initPosition);
acceleration = 2;
velocity = 0;
onTopOfBlock = false;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例12: Emitter
public Emitter(Vector2 position, Texture2D sprite, Color color, int size)
{
this.position = position;
this.sprite = sprite;
this.color = color;
this.size = size;
}
示例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);
}
示例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]);
}
示例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);
}
}