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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Taco Sniper

Pages: [1]
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:

#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-

2
General / Fatal Error LNK 2001
« on: March 22, 2014, 03:43:11 am »
Hey there,
I recently moved from SFML-1.6 to SFML-2.1, and have encountered error 2001. The full error is:
1>VisibleGameObject.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall VisibleGameObject::Draw(class sf::RenderWindow &)" (?Draw@VisibleGameObject@@UAEXAAVRenderWindow@sf@@@Z)
1>VisibleGameObject.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall VisibleGameObject::SetPosition(float,float)" (?SetPosition@VisibleGameObject@@UAEXMM@Z)
I have never encountered this error before, and after much Google-ing, I have found nothing to resolve it. Thus I came here to see if the SFML community is able to help.
Thanks in advance,
-TacoSniper-

3
Graphics / SFML-1.6 not recognising Image
« on: March 20, 2014, 11:29:23 pm »
Hey there,
I have started a project using SFML-1.6 for C++ in VS 2010, and I have come across the problem of Image, Sprite, and RenderWindow all not being deemed as not being a member of sf::. This is very irritating as I have no idea how to resolve the problem, and thus I am here. Hopefully someone here knows how to solve this issue, and I may continue to use SFML without hitch.
Thanks in advance,
-TacoSniper-

Pages: [1]