In other words, you want to allocate the array with new[]?
Don't use raw pointers, arrays and especially not new
@skadush
Use smart pointers, and/or STL containers with ordinary objects. The latter does memory management itself (on the heap), the former could be used for virtual polymorphism, and also uses the heap. Smart pointers use the concept of RAII, which means they behave well in terms of destruction, and can't leak memory. Smart pointers are more like the C# new - they are destroyed automatically, where as C++ new is not.
One can construct an object first, then put in in the container.
The functions std::make_unique and std::make_shared take arguments which effectively construct an object.
How would you call this function (just an example) : GameEntity(sf::Vector2f position, sf::Texture image,sf::Sprite sprite, sf::RenderWindow& window, float scale, sf::Vector2f velocity);
> Why does your every reply got reported? Did you just report yourself?
Probably someone hates me so he did this.
> Anyway this is how I call...
Okay, you can use this :
1 2 3 4 5 6 7 8 9 10 11
// Create a 8x8x64 board
std::unique_ptr<GameEntity> bricks[8][8];
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
bricks[i][j] = std::unique_ptr<GameEntity> (new GameEntity[64]);
for (int k = 0; k < 64; k++)
new (&bricks[i][j][k]) GameEntity(position,image,sprite,window,scale,sf::Vector2f(500,0));
}
}
im not really sure whats going on but why does your every reply got reported?
Just thought I would let you know: closed account is a troll. Messages to admin have been sent by various people about this. Note that it may be more than one person doing the reporting. Be very wary of the advice that is offered by this user. For example: how many GameEntity objects are created by this last version of the code?
I am pretty sure there is documentation you can read about sfml, probably lots of examples.