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

Author Topic: Vector of shapes  (Read 916 times)

0 Members and 1 Guest are viewing this topic.

tandan_prashant

  • Newbie
  • *
  • Posts: 3
    • View Profile
Vector of shapes
« 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));
        }
}
 

« Last Edit: February 25, 2018, 04:20:48 pm by tandan_prashant »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Vector of shapes
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

tandan_prashant

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Vector of shapes
« Reply #2 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

 

anything