Ejemplo n.º 1
0
 /// <summary>
 /// Checks if this sprites pixels intersect with another sprite
 /// This is more painful than checking rectangles
 /// </summary>
 /// <param name="OtherSprite"></param>
 /// <returns></returns>
 public virtual bool PerPixelCollision2(Sprite2 OtherSprite)
 {
     return(IntersectPixels(this.spriteTransform, this.spriteTexture.Width,
                            this.spriteTexture.Height, this.SpriteTextureData,
                            OtherSprite.spriteTransform, OtherSprite.spriteTexture.Width,
                            OtherSprite.spriteTexture.Height,
                            OtherSprite.SpriteTextureData));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks if this sprites pixels intersect with another sprite
        /// This is more painfull than checking rectangles
        /// </summary>
        /// <param name="OtherSprite"></param>
        /// <returns></returns>
        public bool PerPixelCollision(Sprite2 OtherSprite)
        {
            Color[] OtherSpriteColors;
            Color[] SpriteColors;

            //GraphicsDevice.Textures[0] = null;          //Bug

            /*
             * Exception thrown
             * The operation was aborted. You may not modify a resource that has been set on a
             * device, or after it has been used within a tiling bracket.
             */

            OtherSpriteColors = new Color[OtherSprite.spriteTexture.Width *
                                          OtherSprite.spriteTexture.Height];
            SpriteColors = new Color[this.spriteTexture.Width * this.spriteTexture.Height];

            this.spriteTexture.GetData <Color>(SpriteColors);

            OtherSprite.spriteTexture.GetData <Color>(OtherSpriteColors);

            return(IntersectPixels(this.locationRect, SpriteColors,
                                   OtherSprite.locationRect, OtherSpriteColors));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Checks for intersection of this sprite and another sprite
 /// </summary>
 /// <param name="OtherSprite">Other Sprite</param>
 /// <returns>true if the two sprites intersect otherwise returns false</returns>
 public bool Intersects(Sprite2 OtherSprite)
 {
     return(Sprite2.Intersects(this.locationRect, OtherSprite.locationRect));
 }