void Update() { if (currentAnimation != null) { if (currentAnimation.tick(Time.deltaTime)) { // animation done. handle the completion rule switch (currentAnimation.animationState.completeRule) { case SKSpriteAnimationState.CompleteRule.DestorySprite: Destroy(gameObject); break; case SKSpriteAnimationState.CompleteRule.HideSprite: renderer.enabled = false; break; case SKSpriteAnimationState.CompleteRule.RevertToOriginalSprite: setUVs(spriteSheet.textureInfoForImage(sourceImageName).uvRect); break; } currentAnimation = null; } } }
public void startAnimation(string name) { // if we dont have this one loaded yet, load it up if (animations == null || !animations.ContainsKey(name)) { preloadAnimations(name); } if (currentAnimation == null) { currentAnimation = new SKSpriteAnimation(this); } currentAnimation.animationState = animations[name]; }
void Update() { if( currentAnimation != null ) { if( currentAnimation.tick( Time.deltaTime ) ) { // animation done. handle the completion rule switch( currentAnimation.animationState.completeRule ) { case SKSpriteAnimationState.CompleteRule.DestorySprite: Destroy( gameObject ); break; case SKSpriteAnimationState.CompleteRule.HideSprite: renderer.enabled = false; break; case SKSpriteAnimationState.CompleteRule.RevertToOriginalSprite: setUVs( spriteSheet.textureInfoForImage( sourceImageName ).uvRect ); break; } currentAnimation = null; } } }
public void startAnimation( string name ) { // if we dont have this one loaded yet, load it up if( animations == null || !animations.ContainsKey( name ) ) preloadAnimations( name ); if( currentAnimation == null ) currentAnimation = new SKSpriteAnimation( this ); currentAnimation.animationState = animations[name]; }