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.


Messages - tundra010

Pages: [1]
1
Graphics / Issues with Layers
« on: February 13, 2011, 02:58:43 am »
:D
Thanks for the help!

2
Graphics / Issues with Layers
« on: February 13, 2011, 12:32:09 am »
Thanks for the help!
But, could you show me your solution?

3
Graphics / Issues with Layers
« on: February 12, 2011, 11:59:59 pm »
What if I do something like this:

Code: [Select]
layer.CreateShape(/*Parameters*/);

This would create a shape inside the vector in Layer, but not return the pointer, and CreateShape() would be void. Then, I could access the shape by

Code: [Select]
layer.GetVector()[0]

Or something similar to that. Is that a good idea?

4
Graphics / Issues with Layers
« on: February 12, 2011, 10:58:57 pm »
Thank you for replying!
The first error is fixed by adding "const" at the end, but how do I fix the second error? How can I not copy the object?

5
Graphics / Issues with Layers
« on: February 12, 2011, 06:28:48 pm »
Hello! This is my first post on SFML forums.

Recently, I have started a project in which I need a layer class, to group many drawables into one drawable. I have searched the forums, and I found some example code, which I tried to modify for my needs. However, I get strange compiler errors. Here is the code, first, then the errors:

Layer.h:
Code: [Select]

#include <SFML/Graphics.hpp>

class Layer : public sf::Drawable
{
public:
    void AddDrawable(sf::Shape d);
protected:
    typedef std::vector<sf::Shape> DrawableList;
    virtual void Render(sf::RenderTarget &target);
private:
    DrawableList myDrawables;
};



Layer.cpp:
Code: [Select]

#include "Layer.h"

void Layer::AddDrawable(sf::Shape d)
{
    myDrawables.push_back(d);
}

void Layer::Render(sf::RenderTarget &target)
{
    for(unsigned int f = 0; f < myDrawables.size(); f++)
    {
        target.Draw(*myDrawables[f]);
    }
}



Trying to use Layer:
Code: [Select]

Layer a;
a.AddDrawable(sf::Shape::Rectangle(10, 10, 40, 40, sf::Color(255, 200, 0), 5, sf::Color(0, 255, 255)));
a.SetPosition(60, 50);
App.Draw(a);


The compiler errors I get are
-error: cannot declare variable 'a' to be of abstract type 'Layer'
-error: no matching function for call to 'Layer::AddDrawable(sf::Shape)'

Any help would be greatly appreciated!
Thank you!

Pages: [1]