Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Buttons and Menu, please help.  (Read 3159 times)

0 Members and 1 Guest are viewing this topic.

strielokdzielny

  • Newbie
  • *
  • Posts: 1
    • View Profile
Buttons and Menu, please help.
« on: March 04, 2012, 10:37:14 am »
Hello,

I am a beginner. I have a problem. I want to make menus and buttons in SFML. I do not know how to do it. I would do such a thing: when you click on the button opens a window or play a game.

Forgive me for my English :)

PS. I work on SFML 1.6


Please help.

mateandmetal

  • Full Member
  • ***
  • Posts: 171
  • The bird is the word
    • View Profile
    • my blog
Buttons and Menu, please help.
« Reply #1 on: March 04, 2012, 09:21:05 pm »
You can use a GUI library for SFML.. like SFGUI, TGUI, etc.
- Mate (beverage) addict
- Heavy metal addict _lml
- SFML 2 addict
- My first (and free) game: BichingISH!

robvleugel

  • Newbie
  • *
  • Posts: 29
    • View Profile
Buttons and Menu, please help.
« Reply #2 on: March 04, 2012, 09:48:35 pm »
There is no integrated GUI in SFML, you can either use a third party GUI like SFGUI, or create the GUI yourself.

Creating the GUI yourself means you'll create a button in paint, add a sf::Sprite to your window with your button image as texture. Than you should write code like:

Code: [Select]

//pseudocode
if(mouse.x >= button.x && mouse.x <= button.x+button.width && mouse.isPressed() && mouse.y >= button.y && mouse.y <= button.y+button.height){OnClick()}


You probably want to put this into a class and add some slightly advanced code with different button textures on mouse hoover and button press, but you should get the point.

 

anything