コード例 #1
0
        private void SequenceCompleted()
        {
            if (mDelegate != null)
            {
                mDelegate(mRunningSequence.Name);
            }

            int nextSeqId = mRunningSequence.ChainedSequenceId;
            mRunningSequence = null;

            if (nextSeqId != -1)
            {
                RunAnimations(nextSeqId, 0);
            }
        }
コード例 #2
0
ファイル: CCBReader.cs プロジェクト: KogleDK/cocos2d-xna-1
        private bool ReadSequences()
        {
            List<CCBSequence> sequences = mActionManager.Sequences;

            int numSeqs = ReadInt(false);

            for (int i = 0; i < numSeqs; i++)
            {
                var seq = new CCBSequence();

                seq.Duration = ReadFloat();
                seq.Name = ReadCachedString();
                seq.SequenceId = ReadInt(false);
                seq.ChainedSequenceId = ReadInt(true);

                sequences.Add(seq);
            }

            mActionManager.AutoPlaySequenceId = ReadInt(true);
            return true;
        }
コード例 #3
0
        public void RunAnimations(int nSeqId, float fTweenDuration)
        {
            Debug.Assert(nSeqId != -1, "Sequence id couldn't be found");

            mRootNode.StopAllActions();

            foreach (var pElement in mNodeSequences)
            {
                CCNode node = pElement.Key;
                node.StopAllActions();

                // Refer to CCBReader::readKeyframe() for the real type of value
                Dictionary<int, Dictionary<string, CCBSequenceProperty>> seqs = pElement.Value;

                var seqNodePropNames = new List<string>();

                Dictionary<string, CCBSequenceProperty> seqNodeProps;
                if (seqs.TryGetValue(nSeqId, out seqNodeProps))
                {
                    // Reset nodes that have sequence node properties, and run actions on them
                    foreach (var pElement1 in seqNodeProps)
                    {
                        string propName = pElement1.Key;
                        CCBSequenceProperty seqProp = pElement1.Value;
                        seqNodePropNames.Add(propName);

                        SetFirstFrame(node, seqProp, fTweenDuration);
                        RunAction(node, seqProp, fTweenDuration);
                    }
                }

                // Reset the nodes that may have been changed by other timelines
                Dictionary<string, object> nodeBaseValues;
                if (mBaseValues.TryGetValue(node, out nodeBaseValues))
                {
                    foreach (var pElement2 in nodeBaseValues)
                    {
                        if (!seqNodePropNames.Contains(pElement2.Key))
                        {
                            object value = pElement2.Value;

                            if (value != null)
                            {
                                SetAnimatedProperty(pElement2.Key, node, value, fTweenDuration);
                            }
                        }
                    }
                }
            }

            // Make callback at end of sequence
            CCBSequence seq = GetSequence(nSeqId);
            CCAction completeAction = new CCSequence (
                new CCDelayTime (seq.Duration + fTweenDuration),
                new CCCallFunc(SequenceCompleted)
                );

            mRootNode.RunAction(completeAction);

            // Set the running scene
            mRunningSequence = GetSequence(nSeqId);
        }