Witam! Pisząc podstawę gry, chciałem żeby klasa TPlayer
(moja klasa) miała tablicę TPicture
. Muszę tworzyć ją dynamicznie, tak mi nakazuje Builder. Więc mam taki kod:
class TPlayer
{
public:
int x;
int y;
int health;
bool fire;
int fire_delay;
int max_frames;
TPicture *frame; //ta zmienna
TPlayer(int _x, int _y, int _health, int _fire_delay, int _max_frames)
{
x = _x;
y = _y;
health = _health;
fire_delay = _fire_delay;
max_frames = _max_frames;
fire = false;
frame = new TPicture [...]; //tu obojętnie co wstawie czy 2 czy 'max_frames' mam 'access violation'
}
};
Chciałem, aby każda klatka miała swój obraz, czyli chciałem utworzyć tablicę, no niestety program się sypie. Co robie źle, i jak to poprawić? Proszę o odpowiedź.