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

Author Topic: How to declare a shape in a header  (Read 905 times)

0 Members and 1 Guest are viewing this topic.

dan185

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
How to declare a shape in a header
« on: November 13, 2013, 04:15:22 am »
Can someone give me a dumbed down example of how to declare a function in a header that declares a certain shape based on parameters passed to it? One that can declare multiple shapes by calling it multiple times?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: How to declare a shape in a header
« Reply #1 on: November 13, 2013, 07:40:33 am »
CreateShape.hpp
#ifndef CREATESHAPE_HPP
#define CREATESHAPE_HPP

sf::ConvexShape createShape(const sf::Color& color);

#endif

CreateShape.cpp
#include "CreateShape.hpp"

sf::ConvexShape createShape(const sf::Color& color)
{
    sf::ConvexShape shape;
    shape.setFillColor(color);
    ...
    return shape;
}

But that's basic C++ knowledge. You should really learn the language before using SFML, or you will constantly get stuck at minor tasks, which is very frustrating...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: