Exemple #1
0
		public override void Initialize(InitializeParameters p)
		{
			base.Initialize(p);

            int textureWidth = this.SourceRectangle.HasValue ? (int)this.SourceRectangle.Value.Width : this.texture.Image.Width;

            if (this.FrameBounds.Width * FrameCount > textureWidth)
                throw new InvalidOperationException("Specified FrameCount exceeds the Width of the texture");

            this.originalSourceRectangle = this.SourceRectangle;
		}
 internal void Draw(Texture2D texture2D, Vector2 location, System.Drawing.RectangleF?sourceRectangle, Color color, double rotation, Vector2 origin, Vector2 scale, SpriteEffects spriteEffects, float layerDepth)
 {
     if (sourceRectangle.HasValue)
     {
         sourceRectangle.Value.ToRectangle(ref tmpRect2);
         base.Draw(texture2D, location, tmpRect2, color, (float)rotation, origin, scale, spriteEffects, layerDepth);
     }
     else
     {
         base.Draw(texture2D, location, null, color, (float)rotation, origin, scale, spriteEffects, layerDepth);
     }
 }
Exemple #3
0
        public override void Initialize(InitializeParameters p)
        {
            base.Initialize(p);

            int textureWidth = this.SourceRectangle.HasValue ? (int)this.SourceRectangle.Value.Width : this.texture.Image.Width;

            if (this.FrameBounds.Width * FrameCount > textureWidth)
            {
                throw new InvalidOperationException("Specified FrameCount exceeds the Width of the texture");
            }

            this.originalSourceRectangle = this.SourceRectangle;
        }
Exemple #4
0
        public static void ToRectangle(this System.Drawing.RectangleF?rectF, ref Rectangle?rect)
        {
            if (rectF == null)
            {
                rect = null;
                return;
            }

            var result = new Rectangle();

            rectF.Value.ToRectangle(ref result);

            rect = result;
        }
Exemple #5
0
		public override void Initialize (InitializeParameters p)
		{
			base.Initialize (p);

            if (string.IsNullOrEmpty(this.TextureId))
                throw new InvalidOperationException(string.Format(
                    "TextureId must be specified. Image: '{0}'", this.Id
                ));

            this.texture = this.FindGlobal(this.TextureId) as XTextureResource;
			
			if (this.texture == null)
				throw new InvalidOperationException(string.Format(
					"Texture was not found. Image: '{0}' TextureId: '{1}'", this.Id, this.TextureId
                ));

            this.SourceRectangle = this.texture.SourceRectangle;
		}
Exemple #6
0
        public override void Initialize(InitializeParameters p)
        {
            base.Initialize(p);

            if (string.IsNullOrEmpty(this.TextureId))
            {
                throw new InvalidOperationException(string.Format(
                                                        "TextureId must be specified. Image: '{0}'", this.Id
                                                        ));
            }

            this.texture = this.FindGlobal(this.TextureId) as XTextureResource;

            if (this.texture == null)
            {
                throw new InvalidOperationException(string.Format(
                                                        "Texture was not found. Image: '{0}' TextureId: '{1}'", this.Id, this.TextureId
                                                        ));
            }

            this.SourceRectangle = this.texture.SourceRectangle;
        }
        internal void Draw(Texture2D texture2D, System.Drawing.RectangleF screenBounds, System.Drawing.RectangleF?sourceRectangle, Color actualBackColor)
        {
            screenBounds.ToRectangle(ref tmpRect1);

            if (sourceRectangle.HasValue)
            {
                sourceRectangle.Value.ToRectangle(ref tmpRect2);
                base.Draw(texture2D, tmpRect1, tmpRect2, actualBackColor);
            }
            else
            {
                base.Draw(texture2D, tmpRect1, null, actualBackColor);
            }
        }