public TextureButton(Texture2D texture, Vector2 position, SpriteBatch sb) { _texture = texture; _position = position; _sb = sb; _size = new Vector2(_texture.Width, _texture.Height); _halfSize = _size/2f; _activeBox = new AABB( - _halfSize, _halfSize).Inflate(new Vector2(20f)); }
public TextButton(Vector2 position, SpriteFont font, string text, SpriteBatch sb) { _position = position; _font = font; _text = text; _sb = sb; _size = _font.MeasureString(_text); _halfSize = _size / 2f; _activeBox = new AABB(- _halfSize, _halfSize).Inflate(new Vector2(20f)); _center = _activeBox.GetCenter(); }
/// <summary> /// Check if 2 AABB's intersects /// </summary> /// <param name="aabb1">The aabb1.</param> /// <param name="aabb2">The aabb2.</param> /// <returns></returns> public static bool Intersect(AABB aabb1, AABB aabb2) { if (aabb1._min.X > aabb2._max.X || aabb2._min.X > aabb1._max.X) { return false; } if (aabb1._min.Y > aabb2.Max.Y || aabb2._min.Y > aabb1.Max.Y) { return false; } return true; }
public AABB(AABB aabb) { _min = aabb.Min; _max = aabb.Max; }