SDL#2 Animations gestion du fond (effacage) a faire
This commit is contained in:
parent
1dcbae6a14
commit
7a43c382a5
|
@ -25,31 +25,60 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
|
||||
|
||||
/* [4] On ajoute une sprite
|
||||
/* [4] On ajoute Une animation
|
||||
=========================================================*/
|
||||
/* (1) On met un fond */
|
||||
int white[] = {255, 255, 255};
|
||||
Sprite *coin_background = new Sprite(
|
||||
white,
|
||||
(SDL_Rect){0, 0, 180, 200}
|
||||
);
|
||||
|
||||
|
||||
/* (2) On enregistre les frames de l'animation */
|
||||
SpriteGroup animated_coin;
|
||||
animated_coin.add( new Sprite(
|
||||
"src/coins.jpg",
|
||||
(SDL_Rect){0, 0, 180, 200},
|
||||
(SDL_Rect){57, 50, 180, 200}
|
||||
) );
|
||||
// On ajoute un fond entre chaque pour cacher si chgt taille
|
||||
animated_coin.add( coin_background );
|
||||
|
||||
/* (1) On enregistre les frames de l'animation */
|
||||
for( int i = 0 ; i < 7 ; i++ ){
|
||||
|
||||
animated_coin.add( new Sprite(
|
||||
"src/coins.jpg",
|
||||
(SDL_Rect){0, 0, 180, 180},
|
||||
(SDL_Rect){57+168*i, 40, 180, 180}
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
animated_coin.add( new Sprite(
|
||||
"src/coins.jpg",
|
||||
(SDL_Rect){0, 0, 180, 200},
|
||||
(SDL_Rect){57+200, 50, 180, 200}
|
||||
) );
|
||||
animated_coin.add( coin_background );
|
||||
|
||||
animated_coin.add( new Sprite(
|
||||
"src/coins.jpg",
|
||||
(SDL_Rect){30, 0, 150, 200},
|
||||
(SDL_Rect){57+200*2, 50, 180, 200}
|
||||
) );
|
||||
animated_coin.add( coin_background );
|
||||
|
||||
animated_coin.add( new Sprite(
|
||||
"src/coins.jpg",
|
||||
(SDL_Rect){80, 0, 100, 200},
|
||||
(SDL_Rect){57+200*3-30, 50, 180, 200}
|
||||
) );
|
||||
animated_coin.add( coin_background );
|
||||
|
||||
animated_coin.add( new Sprite(
|
||||
"src/coins.jpg",
|
||||
(SDL_Rect){30, 0, 150, 200},
|
||||
(SDL_Rect){57+200*4+10, 50, 180, 200}
|
||||
) );
|
||||
animated_coin.add( coin_background );
|
||||
|
||||
|
||||
|
||||
|
||||
/* [5] On lance l'animation en parallele
|
||||
=========================================================*/
|
||||
thread* anim = animated_coin.animate(mgr->window(), 1000 );
|
||||
thread* anim = animated_coin.animate(mgr->window(), 500 );
|
||||
anim->detach(); // On laisse le thread tourner
|
||||
delete anim; // On le supprime ensuite
|
||||
|
||||
|
|
BIN
SDL#2/main.o
BIN
SDL#2/main.o
Binary file not shown.
Loading…
Reference in New Issue