示例#1
0
 /// <summary>
 /// Instantiates a RenderTexture from the given Texture.
 /// </summary>
 /// <param name="source">Texture to use as a base for the new RenderTexture.</param>
 public RenderTexture( TextureAsset source )
     : this(source.Width, source.Height)
 {
     Color[] colorData = new Color[source.Width * source.Height];
     source.Texture2D.GetData<Color>(colorData);
     RenderTarget2D.SetData<Color>(colorData);
 }
示例#2
0
        public GameBackground( TextureAsset background )
        {
            Depth = 100;
            texture = background;

            image = new Image(texture, false);
            image.Scale = Engine.Instance.Screen.Size / texture.Size;

            Add(image);
        }
示例#3
0
 /// <summary>
 /// Renders a Texture using the given parameters.
 /// </summary>
 /// <param name="texture">The Texture to render.</param>
 /// <param name="rect">Source clipping rectangle to use.</param>
 /// <param name="position">The position to render it at.</param>
 /// <param name="color">The Color to blend with.</param>
 /// <param name="alpha">The transparency to use.</param>
 /// <param name="origin">The origin of the Texture.</param>
 /// <param name="scale">The scaling factors.</param>
 /// <param name="rotation">The rotation.</param>
 public static void Texture(TextureAsset texture, Rectangle rect, Vector2 position, Color color, float alpha, Vector2 origin, Vector2 scale, Angle rotation)
 {
     SpriteBatch.Draw(texture.Texture2D, Calc.Floor(position), rect, color * Math.Min(alpha, 1), rotation.Radians, origin, scale, Effects, 0);
 }
示例#4
0
 /// <summary>
 /// Renders a Texture using the given position and color blending values.
 /// </summary>
 /// <param name="texture">The Texture to use.</param>
 /// <param name="rect">Source clipping rectangle to use.</param>
 /// <param name="position">The position to render it at.</param>
 /// <param name="color">The Color to blend with.</param>
 /// <param name="alpha">The transparency to use.</param>
 public static void Texture(TextureAsset texture, Rectangle rect, Vector2 position, Color color, float alpha = 1.0f)
 {
     SpriteBatch.Draw(texture.Texture2D, Calc.Floor(position), rect, color * Math.Min(alpha, 1));
 }
示例#5
0
 /// <summary>
 /// Renders a Texture using the current rendering state.
 /// </summary>
 /// <param name="texture">The Texture to use.</param>
 /// <param name="rect">Source clipping rectangle to use.</param>
 public static void Texture(TextureAsset texture, Rectangle rect)
 {
     SpriteBatch.Draw(texture.Texture2D, Calc.Floor(Position), rect, Color * Math.Min(Alpha, 1), Rotation.Radians, Origin, Scale * Zoom, Effects, 0);
 }
示例#6
0
 public SpriteDefinition(TextureAsset texture, int frameWidth, int frameHeight)
 {
     Texture = texture;
     Width = frameWidth;
     Height = frameHeight;
     Length = (int)(Texture.Width / Width) * (int)(Texture.Height / Height);
     Rects = new Rectangle[Length];
     for (int i = 0; i < Length; ++i)
         Rects[i] = Texture.GetFrame(i, Width, Height);
 }
示例#7
0
 public SubTexture( TextureAsset texture, int x, int y, int width, int height )
 {
     Texture = texture;
     Rect = new Rectangle(x, y, width, height);
 }
示例#8
0
 public Image(TextureAsset texture, bool active)
     : base(active)
 {
     Texture = texture;
 }
示例#9
0
 private void LoadSprite(string textureName, TextureAsset texture)
 {
     foreach (var s in sprites)
         if (s.Value.TextureName == textureName)
         {
             if (s.Value.SubtextureName != null && texture is TextureAtlas)
                 s.Value.Definition = new SpriteDefinition((texture as TextureAtlas)[s.Value.SubtextureName], s.Value.Width, s.Value.Height);
             else
                 s.Value.Definition = new SpriteDefinition(texture, s.Value.Width, s.Value.Height);
             LoadParticle(s.Value);
         }
 }
示例#10
0
 private void LoadParticle(string textureName, TextureAsset texture)
 {
     foreach(var p in particles)
         if (p.Value.TextureName == textureName)
         {
             if (p.Value.SubtextureName != null && texture is TextureAtlas)
                 p.Value.Type.SetSprite((texture as TextureAtlas)[p.Value.SubtextureName], p.Value.Type.Origin, p.Value.Type.Mode);
             else
                 p.Value.Type.SetSprite(texture, p.Value.Type.Origin, p.Value.Type.Mode);
         }
 }
示例#11
0
 public void Apply(TextureAsset texture)
 {
     Apply(texture.Texture2D);
 }
示例#12
0
 public TextureData(TextureAsset source)
     : this(source.Texture2D)
 {
 }