Scrolling Game Development Kit Forum

SGDK Version 2 => Help, Errors, FAQ => Topic started by: Vincent on 2009-03-17, 08:51:13 PM

Title: Animating Dynamic Sprites
Post by: Vincent on 2009-03-17, 08:51:13 PM
Hi guys,

Quick question, I guess the answer is obvious, but I can't find it anywhere...   :blindfold:

I am creating dynamic sprites for "magical attacks" in my game.  These "magical attacks" sprites have only one state (so they get created in the proper state).  I want to animate these sprites.  But, on the "magical attack", if I use the animate script I get an error saying that it is impossible to animate a deactivated sprite.  (The sprite is gone after hitting a tile.)

How do you verify if a sprite is active?  I see the parameter "is active" in the sprite class.  But it doesn't seem available in the dropdown for "if" scripts.  I haven't seen a function able to return if a sprite is active or not.  I guess I'm not the only one trying to determine if a sprite is active or not.  What have I missed?

Thanks a lot! :D
Title: Re: Animating Dynamic Sprites
Post by: durnurd on 2009-03-18, 07:38:13 AM
Make sure that deactivating a sprite happens at the end of the list of rules, so that no other actions can be taken on the sprite after deactivation.  This can be within the end of a first half of an if-else as well, as long as the end of the if-else is the end of all the rules.  For example:

Code: [Select]
If X
  ...
  do stuff
  ...
  deactivate self
else if
  ...
  do stuff
  ...
end if
Title: Re: Animating Dynamic Sprites
Post by: Vincent on 2009-03-18, 07:42:16 AM
Damn, I should have tought of that...   :tired:

Thanks durnurd. :)