public HealthBar(int maxHealth) { this.maxHealth = maxHealth; health = maxHealth; background = TEXMAN.GetTexture(Textures.TextureName.HealthBarBG); foreground = TEXMAN.GetTexture(Textures.TextureName.HealthBar); recBack = new Rectangle(0, 0, background.Width, background.Height); recFront = new Rectangle(0, 0, foreground.Width, foreground.Height); }
public virtual void LoadContent() { //Get the texture from the texture manager texture = TEXTURES.GetTexture(this.textureName); //Fix the size of the bounds according to the size of the texture (image) bounds.Width = texture.Width; bounds.Height = texture.Height; source.Width = bounds.Width; source.Height = bounds.Height; //Move the bounds rectangle to the correct position on screen MoveTo(this.position); //set the center of the image offset for drawing purposed centerImg = new Vector2((float)texture.Width / 2.0f, (float)texture.Height / 2.0f); //set the collision and detection radii collisionRadius = Math.Max((float)texture.Height / 2.0f, (float)texture.Width / 2.0f) - collisionOffset; detectionRadius = collisionRadius + detectionOffset; }