This is part of my Manager
int CreaSprite(string nome_sprite, string nome_immagine, float x, float y, float size_x, float size_y, int z_index, int stato){
int _temp_id = DammiSpriteId(nome_sprite);
int _img_id = DammiImmagineId(nome_immagine);
int _ris = _temp_id;
if(_temp_id == -1){
_Sprites data;
data.id_sprite = agk::CreateSprite(_img_id);
_ris = data.id_sprite;
data.nome_sprite = nome_sprite;
//agk::SetSpriteUVBorder(data.id_sprite, border);
agk::SetSpritePosition(data.id_sprite, x, y);
agk::SetSpriteDepth(data.id_sprite, z_index);
agk::SetSpriteVisible(data.id_sprite, stato);
agk::SetSpriteSize(data.id_sprite, size_x, size_y);
Sprites.push_back(data);
} else {
agk::SetSpriteImage (_temp_id, _img_id);
//agk::SetSpriteUVBorder(_temp_id, border);
agk::SetSpritePosition(_temp_id, x, y);
agk::SetSpriteDepth(_temp_id, z_index);
agk::SetSpriteVisible(_temp_id, stato);
agk::SetSpriteSize(_temp_id, size_x, size_y);
}
//printf("Sprite : %i - Nome : %s\n", _ris, nome_sprite.c_str());
return _ris;
}
And this is the new version of fireworks...
//Fuochi D'Artificio
if(_fuochi && fps % 2 == 0){
for(int w = 0; w < Fire.size(); w++){
//Posizione fuochi d'artificio
Fire[w].cy += Fire[w].vel;
if(Fire[w].cy < 200){
if(Fire[w].fr == 1){
Fire[w].fr = 2;
} else if(Fire[w].fr == 2){
Fire[w].fr = 1;
}
} else {
Fire[w].fr++;
if(Fire[w].fr > 9){
Fire[w].fr = 1;
Fire[w].cy = 0;
}
}
printf("F : %i - Frame : %i - Co2 : %i\n", Fire[w].id_sp, Fire[w].fr, Fire[w].cy);
agk::SetSpriteFrame(Fire[w].id_sp, Fire[w].fr);
agk::SetSpriteY(Fire[w].id_sp, Fire[w].oy - Fire[w].cy);
agk::SetSpriteVisible(Fire[w].id_sp, 1);
}
}
And the vector now is...
void InizializzaFuochi(){
Fire[0].cy = 0;
Fire[0].vel = 2;
Fire[0].fr = 1;
Fire[0].oy = Opzioni[0].device_height - 100;
Fire[0].id_sp = CreaSprite("fu1", "fverde", 0, Fire[0].oy, 200, 200, 20, 0);
agk::SetSpriteAnimation(Fire[0].id_sp, 100, 100, 9);
Fire[1].cy = 0;
Fire[1].vel = 3;
Fire[1].fr = 1;
Fire[1].oy = Opzioni[0].device_height - 200;
Fire[1].id_sp = CreaSprite("fu2", "fblu", int(((Opzioni[0].device_width / 2) - (Opzioni[0].device_width / 3))) + 50, Fire[1].oy, 200, 200, 20, 0);
agk::SetSpriteAnimation(Fire[1].id_sp, 100, 100, 9);
Fire[2].cy = 0;
Fire[2].vel = 2;
Fire[2].fr = 1;
Fire[2].oy = Opzioni[0].device_height - 100;
Fire[2].id_sp = CreaSprite("fu3", "fviola", (Opzioni[0].device_width / 2) - 100, Fire[2].oy, 200, 200, 20, 0);
agk::SetSpriteAnimation(Fire[2].id_sp, 100, 100, 9);
Fire[3].cy = 0;
Fire[3].vel = 3;
Fire[3].fr = 1;
Fire[3].oy = Opzioni[0].device_height - 200;
Fire[3].id_sp = CreaSprite("fu4", "fblu", Opzioni[0].device_width - (Opzioni[0].device_width / 3) - 75, Fire[3].oy, 200, 200, 20, 0);
agk::SetSpriteAnimation(Fire[3].id_sp, 100, 100, 9);
Fire[4].cy = 0;
Fire[4].vel = 2;
Fire[4].fr = 1;
Fire[4].oy = Opzioni[0].device_height - 100;
Fire[4].id_sp = CreaSprite("fu5", "fverde", Opzioni[0].device_width - 200, Fire[4].oy, 200, 200, 20, 0);
agk::SetSpriteAnimation(Fire[4].id_sp, 100, 100, 9);
}
Ok now the fireworks don't fire the 12 sprite doesn't exist, but now only 1 fire go over the max count!!!
Ahahah make me crazy!
Long life to Steve!