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

Author Topic: Main Menu Buttons  (Read 2174 times)

0 Members and 1 Guest are viewing this topic.

Taco Sniper

  • Newbie
  • *
  • Posts: 6
    • View Profile
Main Menu Buttons
« on: May 19, 2014, 10:55:02 am »
Hi,
I recently tried making a main menu for my game I'm working on, when I came to a strange error.
The error is "this declaration has no storage class or type specifier" on the last 2 parts of the options button and I have no clue as to what it means or what is causing it. This is my code for the main menu:

#include "stdafx.h"
#include "MainMenu.h"
#include "SFML/Graphics.hpp"
#include <iostream>
#include <stdio.h>

MainMenu::MenuResult MainMenu::Show(sf::RenderWindow& window)
{
        sf::Texture menuTexture;
        menuTexture.loadFromFile("images/mainmenu.png");
        sf::Sprite sprite(menuTexture);

        MenuItem playButton;
        playButton.rect.top    = 50;
        playButton.rect.height = 250;
        playButton.rect.left   = 50;
        playButton.rect.width  = 300;
        playButton.action      = Play;

        MenuItem exitButton;
        exitButton.rect.top    = 440;
        exitButton.rect.height = 590;
        exitButton.rect.left   = 50;
        exitButton.rect.width  = 300;
        exitButton.action      = Exit;

        MenuItem optionsButton;
        optionsButton.rect.top    = 250;
        optionsButton.rect.height = 400;
        optionsButton.rect.left   = 50;
        optionsButton.rect.width  = 300;
        optionsButton.action      = Options;

        _menuItems.push_back(playButton);
        _menuItems.push_back(exitButton);
        _menuItems.push_back(optionsButton);

        window.draw(sprite);
        window.display();

        return GetMenuResponse(window);
}

MainMenu::MenuResult Mainmenu::HandleClick(int x, int y)
{
        std::list<MenuItem>::iterator it;

        for(it = _menuItems.begin(); it != _menuItems.end(); it++)
        {
                sf::Rect<int> menuItemRect = (*it).rect;
                if(    menuItemRect.height > y
                        && menuItemRect.top    < y
                        && menuItemRect.left   < x
                        && menuitemRect.width  > x)
                {
                        return (*it).action;
                }
        }
        return Nothing;
}

MainMenu::MenuResult MainMenu::GetMenuResponse(sf::RenderWindow& window)
{
        sf::Event menuEvent;

        while(true)
        {
                while(window.pollEvent(menuEvent))
                {
                        if(menuEvent.type == sf::Event::MouseButtonPressed)
                        {
                                return HandleClick(menuEvent.mouseButton.x, menuEvent.mouseButton.y);
                        }
                        if(menuEvent.ype == sf::Event::Closed)
                        {
                                return Exit;
                        }
                }
        }
}

If you'd like to see the whole project just let me know,
Thanks in advance
-Taco Sniper-
« Last Edit: May 19, 2014, 12:16:00 pm by Taco Sniper »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Main Menu Buttons
« Reply #1 on: May 19, 2014, 02:05:16 pm »
This is clearly not an SFML-related problem. Have you searched for the error message already? If you post it here, please adhere to the forum rules (minimal complete example) or at least show us in which line the error occurs. But as mentioned, this kind of problem can be found within seconds using common search engines... Or even by looking at the corresponding lines more carefully.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

didii

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Main Menu Buttons
« Reply #2 on: May 20, 2014, 05:26:50 pm »
It's not this is it? ::)
if(menuEvent.ype == sf::Event::Closed)

On the console you normally have an error code. Microsoft does a very good job documenting the occurrences of these errors with an explanation and examples.

 

anything