1
General / 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:
If you'd like to see the whole project just let me know,
Thanks in advance
-Taco Sniper-
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;
}
}
}
}
#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-