Buenas estoy programando mi juego, y me he dado cuenta del potencial de los punteros creo, Aquí va mi explicación.
tengo 2 clases:
Héroe y Animación.
antes para tener la cantidad de animaciones que quisiera en Héroe tenia que crear un array.
animaciones[10].
ahora con un puntero hago que apunte a la animación que quiera.
Antes:class heroe{
animacion a[10];
};
Ahora:class heroe{
animacion *a;
};
Lo que hago ahora es definir las animaciones fuera, y apuntar a la que quiera cuando quiera.
un ejemplo :GameAnimation GA1("data/ani-zombie1-right.txt");
GameAnimation GA2("data/ani-zombie2-right.txt");
GameAnimation GA3("data/ani-zombie3-right.txt");
GameAnimation GA4("data/ani-zombie4-right.txt");
GameAnimation GA5("data/ani-zombie5-right.txt");
//h1.SetAnimation(ANIMACION QUE QUIERA); POR EJEMPLO
h1.SetAnimation(GA3);
//AHORA LA ANIMACION DE H1 ES GA3
h1.SetAnimation(GA1);
//AHORA LA ANIMACION DE H1 ES GA1
Bueno que me decís es este el buen uso de los punteros?
PD: Por qué GA1 lo leo como GAY ? xD