GetClipIdByName() public method

Resolves an animation clip by name and returns a unique id. This is a convenient alias to tk2dSpriteAnimation.GetClipIdByName
public GetClipIdByName ( string name ) : int
name string Case sensitive clip name, as defined in .
return int
 public void Start()
 {
     if (Started) return;
     Started = true;
     Transform = transform;
     _growAnimationKey = color + "ShieldGrow";
     var shrinkAnimationKey = color + "ShieldShrink";
     _animation = GetComponent<tk2dAnimatedSprite>();
     _growAnimationClipId = _animation.GetClipIdByName(_growAnimationKey);
     _shrinkAnimationClipId = _animation.GetClipIdByName(shrinkAnimationKey);
     _growDamageTaken = _growClipLength = _animation.anim.clips[_growAnimationClipId].frames.Length - 1;
     _shrinkClipLength = _animation.anim.clips[_shrinkAnimationClipId].frames.Length - 1;
 }
Example #2
0
    void Awake()
    {
        mHeadSprite         = head.GetComponent <tk2dAnimatedSprite>();
        mHeadClipIdleId     = mHeadSprite.GetClipIdByName(headClipIdle);
        mHeadClipGrabId     = mHeadSprite.GetClipIdByName(headClipGrab);
        mHeadClipHoldId     = mHeadSprite.GetClipIdByName(headClipHold);
        mHeadClipThrowId    = mHeadSprite.GetClipIdByName(headClipThrow);
        mHeadClipFireHoldId = mHeadSprite.GetClipIdByName(headClipFireHold);

        mHeadSprite.animationCompleteDelegate = HeadAnimComplete;

        mNeckSprite = neck.GetComponent <tk2dSprite>();

        neck.gameObject.SetActiveRecursively(false);

        foreach (Weapon weapon in weapons)
        {
            weapon.Init(this);
            weapon.gameObject.SetActiveRecursively(false);
        }
    }
Example #3
0
    public override void TStart()
    {
        character = gameObject.GetComponent <SoulAvenger.Character>();
        character.registerAttack(this);
        currentState = AttackStates.IDLE;

        tk2dAnimatedSprite anim = character.getSprite();

        if (anim.GetClipIdByName("spawn") != -1)
        {
            Game.game.playSound(character.spawningSound);
            character.spawningComplete = false;
            character.changeAnimation("spawn", delegate(tk2dAnimatedSprite sprite, int clipId){ character.spawningComplete = true; character.changeAnimation("idle"); });
        }
    }
Example #4
0
    protected void PlayAnim(Entity.Action act)
    {
        if (mSpriteAnim != null)
        {
            if (mActionAnimIds == null)
            {
                mActionAnimIds = new int[(int)Entity.Action.NumActions];
                for (int i = 0; i < mActionAnimIds.Length; i++)
                {
                    mActionAnimIds[i] = mSpriteAnim.GetClipIdByName(((Entity.Action)i).ToString());
                }
            }

            int id = mActionAnimIds[(int)act];
            if (id != -1 && mSpriteAnim.clipId != id)
            {
                mSpriteAnim.Play(id);
            }
        }
    }
Example #5
0
    void Awake()
    {
        mPlayer = player.GetComponent<Player>();

        mHeadSprite = head.GetComponent<tk2dAnimatedSprite>();
        mHeadClipIdleId = mHeadSprite.GetClipIdByName(headClipIdle);
        mHeadClipGrabId = mHeadSprite.GetClipIdByName(headClipGrab);
        mHeadClipHoldId = mHeadSprite.GetClipIdByName(headClipHold);
        mHeadClipThrowId = mHeadSprite.GetClipIdByName(headClipThrow);

        mNeckSprite = neck.GetComponent<tk2dSprite>();
    }
        public AnimData(tk2dAnimatedSprite spr, int defaultId, 
			string moveName, string stopName, Dir dir)
        {
            //omni dir
            if(dir == Dir.NumDir) {
                moveId = spr.GetClipIdByName(moveName);
                if(moveId < 0) {
                    moveId = defaultId;
                }

                stopId = spr.GetClipIdByName(stopName);
                if(stopId < 0) {
                    stopId = defaultId;
                }
            }
            else {
                string nameDir = dir.ToString();

                moveId = spr.GetClipIdByName(moveName + nameDir);
                if(moveId < 0) {
                    moveId = defaultId;
                }

                stopId = spr.GetClipIdByName(stopName + nameDir);
                if(stopId < 0) {
                    stopId = defaultId;
                }
            }
        }
Example #7
0
    void Awake()
    {
        mHeadSprite = head.GetComponent<tk2dAnimatedSprite>();
        mHeadClipIdleId = mHeadSprite.GetClipIdByName(headClipIdle);
        mHeadClipGrabId = mHeadSprite.GetClipIdByName(headClipGrab);
        mHeadClipHoldId = mHeadSprite.GetClipIdByName(headClipHold);
        mHeadClipThrowId = mHeadSprite.GetClipIdByName(headClipThrow);
        mHeadClipFireHoldId = mHeadSprite.GetClipIdByName(headClipFireHold);

        mHeadSprite.animationCompleteDelegate = HeadAnimComplete;

        mNeckSprite = neck.GetComponent<tk2dSprite>();

        neck.gameObject.SetActiveRecursively(false);

        foreach(Weapon weapon in weapons) {
            weapon.Init(this);
            weapon.gameObject.SetActiveRecursively(false);
        }
    }
Example #8
0
    private IEnumerator RandomCustomerFace()
    {
        if(customerSprite_Obj) {
            animatedSprite = customerSprite_Obj.GetComponent<tk2dAnimatedSprite>();

            int r = Random.Range(0, animationClip_name.Length);
            currentPlayAnimatedID = animatedSprite.GetClipIdByName(animationClip_name[r]);
            animatedSprite.Play(currentPlayAnimatedID);
        }

        yield return 0;
    }