コード例 #1
0
ファイル: Sprite2.cs プロジェクト: dsp56001/MonogameBreakOut
 /// <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));
 }
コード例 #2
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 override bool PerPixelCollision2(Sprite2 OtherSprite)
 {
     return(IntersectPixels(this.spriteTransform,
                            this.currentTextureRect.Width,
                            this.currentTextureRect.Height,
                            this.SpriteTextureData,
                            OtherSprite.spriteTransform,
                            OtherSprite.SpriteTexture.Width,
                            OtherSprite.SpriteTexture.Height,
                            OtherSprite.SpriteTextureData));
 }
コード例 #3
0
        public SpriteAnimationAdapter(Game game, Sprite2 sprite)
        {
            this.parent      = sprite;
            spriteAnimations = new List <SpriteAnimation>();

            celAnimationManger = (CelAnimationManager)game.Services.GetService(typeof(ICelAnimationManager));
            if (celAnimationManger == null)
            {
                //throw new Exception("To use a DrawableAnimatedSprite you must a CelAnimationManager to the game as a service!");
                celAnimationManger = new CelAnimationManager(game);
                game.Components.Add(celAnimationManger);
            }
        }
コード例 #4
0
ファイル: Sprite2.cs プロジェクト: dsp56001/MonogameBreakOut
        /// <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));
        }
コード例 #5
0
ファイル: Sprite2.cs プロジェクト: dsp56001/MonogameBreakOut
 /// <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));
 }