public bool Collides(GameObject target) { Sprite sprite = AnimationSequences[CurrentAnimation].Sprites[CurrentFrame]; float x1 = Location.X - sprite.HandleX * Scale; float x2 = x1 + sprite.Image.NaturalWidth * Scale; float y1 = Location.Y - sprite.HandleY * Scale; float y2 = y1 + sprite.Image.NaturalHeight * Scale; Sprite tsprite = target.GetCurrentSprite(); float tx1 = target.Location.X - tsprite.HandleX * Scale; float tx2 = tx1 + tsprite.Image.NaturalWidth * Scale; float ty1 = target.Location.Y - tsprite.HandleY * Scale; float ty2 = ty1 + tsprite.Image.NaturalHeight * Scale; if ((tx2 < x1) || (tx1 > x2) || (ty2 < y1) || (ty1 > y2)) { return(false); } return(Scene.Collision(sprite.Image.Src, tsprite.Image.Src, tx1 - x1, ty1 - y1)); }
public bool Collides(GameObject target) { Sprite sprite = AnimationSequences[CurrentAnimation].Sprites[CurrentFrame]; float x1 = Location.X - sprite.HandleX * Scale; float x2 = x1 + sprite.Image.NaturalWidth * Scale; float y1 = Location.Y - sprite.HandleY * Scale; float y2 = y1 + sprite.Image.NaturalHeight * Scale; Sprite tsprite = target.GetCurrentSprite(); float tx1 = target.Location.X - tsprite.HandleX * Scale; float tx2 = tx1 + tsprite.Image.NaturalWidth * Scale; float ty1 = target.Location.Y - tsprite.HandleY * Scale; float ty2 = ty1 + tsprite.Image.NaturalHeight * Scale; if ((tx2 < x1) || (tx1 > x2) || (ty2 < y1) || (ty1 > y2)) return false; return Scene.Collision(sprite.Image.Src, tsprite.Image.Src, tx1 - x1, ty1 - y1); }