public void AddButton(float percentX, float percentY, string text, RNSEB.OnClick callbackfunc, string spriteNormal = "ButtonNormal", string spriteHighlight = "ButtonHighlight", string spritePress = "ButtonClick", float scale = 0.6f) { int x = (int)(percentX * RNSEB.RESOLUTION.X); int y = (int)(percentY * RNSEB.RESOLUTION.Y); HenryButton b = new HenryButton(x, y, text, callbackfunc, RNSEB.cm, spriteNormal, spriteHighlight, spritePress); b.Scale = scale; Buttons.Add(text, b); }
public HenryButton(int x, int y, string text, RNSEB.OnClick onClick, ContentManager cm, string spriteNormal, string spriteHighlight, string spritePress) : base(cm) { buttonNormal = spriteNormal; buttonHighlight = spriteHighlight; buttonClick = spritePress; base.LoadContent(buttonNormal, true); //load the button background this.Position = new Vector2(x, y); //set the button position where specified this.CenterOrigin(); //draw button measuring from center of texture buttonText = new HenryText(this.Position, RNSEB.ButtonFont, text); buttonText.Color = Color.Red; //set the text color this.cm = cm; //store the content manager reference so we can use it later to swap button textures this.onClick = onClick; //store the lambda function to call when clicked //RNSEB.Win.ClientSizeChanged += new EventHandler<EventArgs>(ResolutionChange); //subscribe to window change event }