Exemple #1
0
        public Test5()
        {
            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
            sp2 = new CCSprite(TestResource.s_pPathSister2);

            sp1.Position = (new CCPoint(100, 160));
            sp2.Position = (new CCPoint(380, 160));

            CCRotateBy rot = new CCRotateBy (2, 360);
            var rot_back = rot.Reverse() as CCActionInterval;
            CCAction forever = new CCRepeatForever ((CCActionInterval)new CCSequence(rot, rot_back));
            forever2 = (CCAction) (forever.Copy());
            forever.Tag = (101);
            forever2.Tag = (102);

            AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
            AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);

            RemoveChild(sp2, true);
            AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);

            // Sprite 1 should run and run
            // Sprite 2 should stop

            sp1.RunAction(forever);
            sp2.RunAction(forever2);

            // Experiment with removing sp2 and re-adding it after cleanup to reproduce an error in child management
//            ScheduleOnce(Stage2OfTest, 2.0f);
            Schedule(addAndRemove, 2.0f);
        }
 public CCLayerMultiplex(CCAction inAction, CCAction outAction, params CCLayer[] layer)
 {
     InitWithLayers(layer);
     m_InAction = inAction;
     m_OutAction = outAction;
     ShowFirstLayerOnEnter = true;
 }
 protected virtual bool InitWithAction(CCAction pAction, float duration)
 {
     if (base.InitWithDuration(duration))
     {
         m_fRate = 1.0f;
         m_pOther = pAction as CCActionInterval;
         return true;
     }
     return false;
 }
Exemple #4
0
 public void StopAction(CCAction action)
 {
     m_pActionManager.RemoveAction(action);
 }
Exemple #5
0
 public CCAction RunAction(CCAction action)
 {
     Debug.Assert(action != null, "Argument must be non-nil");
     m_pActionManager.AddAction(action, this, !m_bIsRunning);
     return action;
 }
        // CCLayer
        public override void OnEnter()
        {
            base.OnEnter();

            m_nCharLimit = 12;

            m_pTextFieldAction = new CCRepeatForever (
                (CCActionInterval)new CCSequence(
                    new CCFadeOut  (0.25f),
                    new CCFadeIn  (0.25f)));
            //m_pTextFieldAction->retain();
            m_bAction = false;

            // add CCTextFieldTTF
            CCSize s = CCDirector.SharedDirector.WinSize;

            m_pTextField = CCTextFieldTTF.TextFieldWithPlaceHolder("<click here for input>",
            TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);
            AddChild(m_pTextField);

            //m_pTextField.setDelegate(this);


            //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)	
            //    // on android, CCTextFieldTTF cannot auto adjust its position when soft-keyboard pop up
            //    // so we had to set a higher position
            //    m_pTextField->setPosition(new CCPoint(s.width / 2, s.height/2 + 50));
            //#else
            //    m_pTextField->setPosition(ccp(s.width / 2, s.height / 2));
            //#endif

            m_pTrackNode = m_pTextField;
        }
 public CCAccelAmplitude(CCAction pAction, float duration) : base(duration)
 {
     InitWithAction(pAction, duration);
 }
 public CCLayerMultiplex(CCAction inAction, CCAction outAction, CCLayer layer)
 {
     InitWithLayer(layer);
     m_InAction = inAction;
     m_OutAction = outAction;
 }
 public CCLayerMultiplex(CCAction inAction, CCAction outAction)
 {
     m_InAction = inAction;
     m_OutAction = outAction;
 }
 public CCLayerMultiplex(CCAction inAction, CCAction outAction, CCLayer layer)
 {
     InitWithLayer(layer);
     m_InAction  = inAction;
     m_OutAction = outAction;
 }
Exemple #11
0
        // CCLayer
        public override void OnEnter()
        {
            base.OnEnter();

            m_nCharLimit = 12;

            m_pTextFieldAction = new CCRepeatForever(
                (CCActionInterval) new CCSequence(
                                       new CCFadeOut(0.25f),
                                       new CCFadeIn(0.25f)));
            //m_pTextFieldAction->retain();
            m_bAction = false;

            // add CCTextFieldTTF
            CCSize s = CCDirector.SharedDirector.WinSize;

            m_pTextField = new CCTextFieldTTF("<click here for input>",
                                              TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);
            AddChild(m_pTextField);

            m_pTrackNode = m_pTextField;
        }
 public CCLayerMultiplex(CCAction inAction, CCAction outAction, params CCLayer[] layer)
 {
     InitWithLayers(layer);
     m_InAction = inAction;
     m_OutAction = outAction;
 }
        // Commented out for now as it does not seem to be used
        //public void Debug()
        //{
        //}

        public void SetCallFunc(CCAction callFunc, string callbackNamed)
        {
            _keyframeCallFuncs.Add(callbackNamed, callFunc);
        }
Exemple #14
0
        public void Update(float dt)
        {
            int count = m_pTargets.Keys.Count;

            while (m_pTmpKeysArray.Length < count)
            {
                m_pTmpKeysArray = new CCNode[m_pTmpKeysArray.Length * 2];
            }

            m_pTargets.Keys.CopyTo(m_pTmpKeysArray, 0);

            for (int i = 0; i < count; i++)
            {
                HashElement elt;
                if (!m_pTargets.TryGetValue(m_pTmpKeysArray[i], out elt))
                {
                    continue;
                }

                m_pCurrentTarget         = elt;
                m_bCurrentTargetSalvaged = false;

                if (!m_pCurrentTarget.Paused)
                {
                    // The 'actions' may change while inside this loop.
                    for (m_pCurrentTarget.ActionIndex = 0;
                         m_pCurrentTarget.ActionIndex < m_pCurrentTarget.Actions.Count;
                         m_pCurrentTarget.ActionIndex++)
                    {
                        m_pCurrentTarget.CurrentAction = m_pCurrentTarget.Actions[m_pCurrentTarget.ActionIndex];
                        if (m_pCurrentTarget.CurrentAction == null)
                        {
                            continue;
                        }

                        m_pCurrentTarget.CurrentActionSalvaged = false;

                        m_pCurrentTarget.CurrentAction.Step(dt);

                        if (m_pCurrentTarget.CurrentActionSalvaged)
                        {
                            // The currentAction told the node to remove it. To prevent the action from
                            // accidentally deallocating itself before finishing its step, we retained
                            // it. Now that step is done, it's safe to release it.

                            //m_pCurrentTarget->currentAction->release();
                        }
                        else if (m_pCurrentTarget.CurrentAction.IsDone)
                        {
                            m_pCurrentTarget.CurrentAction.Stop();

                            CCAction action = m_pCurrentTarget.CurrentAction;
                            // Make currentAction nil to prevent removeAction from salvaging it.
                            m_pCurrentTarget.CurrentAction = null;
                            RemoveAction(action);
                        }

                        m_pCurrentTarget.CurrentAction = null;
                    }
                }

                // only delete currentTarget if no actions were scheduled during the cycle (issue #481)
                if (m_bCurrentTargetSalvaged && m_pCurrentTarget.Actions.Count == 0)
                {
                    DeleteHashElement(m_pCurrentTarget);
                }
            }

            // issue #635
            m_pCurrentTarget = null;
        }
        public void AddAction(CCAction action, CCNode target, bool paused)
        {
            Debug.Assert(action != null);
            Debug.Assert(target != null);

            HashElement element;
            if (!m_pTargets.TryGetValue(target, out element))
            {
                element = new HashElement();
                element.Paused = paused;
                element.Target = target;
                m_pTargets.Add(target, element);
            }

            ActionAllocWithHashElement(element);

            Debug.Assert(!element.Actions.Contains(action));
            element.Actions.Add(action);

            action.StartWithTarget(target);
        }
        public void RemoveAction(CCAction action)
        {
            if (action == null || action.OriginalTarget == null)
            {
                return;
            }

            object target = action.OriginalTarget;
            HashElement element;
            if (m_pTargets.TryGetValue(target, out element))
            {
                int i = element.Actions.IndexOf(action);

                if (i != -1)
                {
                    RemoveActionAtIndex(i, element);
                }
                else
                {
                    CCLog.Log("cocos2d: removeAction: Action not found");
                }
            }
            else
            {
                CCLog.Log("cocos2d: removeAction: Target not found");
            }
        }
 public CCLayerMultiplex(CCAction inAction, CCAction outAction)
 {
     m_InAction  = inAction;
     m_OutAction = outAction;
 }