Jump to content

Photo

kill eweapon when sprite has finished animating


  • Please log in to reply
5 replies to this topic

#1 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 08 January 2017 - 09:17 PM

can someone tell me how to check if a eweapon's sprite has finished animating and is about to loop?

I want to destroy it.

 

here is the code

const int FFC_EXPLOSION_SPRITE     = 96; //Sprite for the explosion.
const int FFC_EXPLOSION_SFX        = 0;
const int FFC_EXPLOSION_EXTEND     = 4; //Size of explosion eweapon.
const int FFC_EXPLOSION_TILEWIDTH  = 2; //Width of explosion, in tiles.
const int FFC_EXPLOSION_TILEHEIGHT = 2; //Height of explosion, in tiles.
 
 
void EnemyExplosions()
{
int x;
int y;
for ( int e = 1; e <= Screen->NumNPCs(); e++) 
{
npc enemy = Screen->LoadNPC(e);
eweapon explosion;
if (enemy->isValid() && enemy->Misc[0] != 1)
{
if (enemy->HP <= 0)
{
enemy->Misc[0] = 1;
x = enemy->X - 8;
y = enemy->Y - 8;
 
explosion = Screen->CreateEWeapon(EW_SCRIPT1);
Game->PlaySound(FFC_EXPLOSION_SFX);
explosion->CollDetection = false; //...that doesn;t hurt anyone...
explosion->X = x;
explosion->Y = y;
explosion->UseSprite(FFC_EXPLOSION_SPRITE); //...using this sprite
 
explosion->Extend = FFC_EXPLOSION_EXTEND; //...with extended size
explosion->TileWidth  = FFC_EXPLOSION_TILEWIDTH; //...this many tiles wide
explosion->TileHeight = FFC_EXPLOSION_TILEHEIGHT; ///...this many tiles high
explosion->CSet = 8;
 
Remove(enemy);
 
//Wait here for animation to end
explosion->DeadState = WDS_ARROW;
explosion->DeadState = WDS_DEAD; //Kill the dummy eweapon
Remove(explosion); //and remove it.
}
}
}
}


#2 Avataro

Avataro

    Quest maker xD

  • Members
  • Real Name:Robin xD
  • Gender:Male
  • Location:Germany

Posted 09 January 2017 - 10:35 AM

explosion->DeadState = explosion->NumFrames*explosion->ASpeed;

Put this ^ under your line:

explosion->UseSprite(FFC_EXPLOSION_SPRITE); //...using this sprite

  • Gégé likes this

#3 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 09 January 2017 - 12:27 PM

how do I remove it?



#4 Avataro

Avataro

    Quest maker xD

  • Members
  • Real Name:Robin xD
  • Gender:Male
  • Location:Germany

Posted 09 January 2017 - 01:21 PM

My line removes it when the animation has finished.



#5 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 09 January 2017 - 01:41 PM

oh ok thankyou



#6 ZoriaRPG

ZoriaRPG

    ZC Contributor & Wiki Editor

  • Members
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 09 January 2017 - 03:32 PM

You should also familiarise yourself with the functions in std.zh, including Remove(*ptr).




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users