SFML community forums

Help => General => Topic started by: tandan_prashant on February 25, 2018, 03:04:52 pm

Title: Vector of shapes
Post by: tandan_prashant on February 25, 2018, 03:04:52 pm
I had been doing this in arrays and was working completely fine but when I tried to do the same thing with vector I am getting errors.

error: 'class std::vector<sf::CircleShape>' has no member named 'setRadius' and 'setFillColor'

In food.h :
class Food{
private:
     std::vector<sf::CircleShape> food[81];
public:
    Food(int rad);
};
 

In food.cpp:
#include "food.h"

Food::Food(int rad){
    for(int i=0;i<81;i++){
        food[i].setRadius(rad);
        food[i].setFillColor(sf::Color(10,200,10));
        }
}
 

Title: Re: Vector of shapes
Post by: eXpl0it3r on February 25, 2018, 08:11:58 pm
You're creating an array with 81 elements of std::vector<sf::CircleShap>, which means you get 81 vectors and a vector of course doesn't have setRadius or setFillColor.
Title: Re: Vector of shapes
Post by: tandan_prashant on February 26, 2018, 04:45:05 am
Thank you so much  :D :D ... and truly speaking  this is what I like about SFML community !   ;D