Ejemplo n.º 1
0
    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;
            }
        }
    }
Ejemplo n.º 2
0
    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];
    }
Ejemplo n.º 3
0
    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;
            }
        }
    }
Ejemplo n.º 4
0
    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];
    }