コード例 #1
0
ファイル: Test5.cs プロジェクト: Karunp/cocos2d-xna
        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);
        }
コード例 #2
0
 public CCLayerMultiplex(CCAction inAction, CCAction outAction, params CCLayer[] layer)
 {
     InitWithLayers(layer);
     m_InAction = inAction;
     m_OutAction = outAction;
     ShowFirstLayerOnEnter = true;
 }
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: CCNode.cs プロジェクト: CartBlanche/cocos2d-xna
 public void StopAction(CCAction action)
 {
     m_pActionManager.RemoveAction(action);
 }
コード例 #5
0
ファイル: CCNode.cs プロジェクト: CartBlanche/cocos2d-xna
 public CCAction RunAction(CCAction action)
 {
     Debug.Assert(action != null, "Argument must be non-nil");
     m_pActionManager.AddAction(action, this, !m_bIsRunning);
     return action;
 }
コード例 #6
0
ファイル: TextInputTest.cs プロジェクト: rtabbara/cocos2d-xna
        // 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;
        }
コード例 #7
0
 public CCAccelAmplitude(CCAction pAction, float duration) : base(duration)
 {
     InitWithAction(pAction, duration);
 }
コード例 #8
0
 public CCLayerMultiplex(CCAction inAction, CCAction outAction, CCLayer layer)
 {
     InitWithLayer(layer);
     m_InAction = inAction;
     m_OutAction = outAction;
 }
コード例 #9
0
 public CCLayerMultiplex(CCAction inAction, CCAction outAction)
 {
     m_InAction = inAction;
     m_OutAction = outAction;
 }
コード例 #10
0
 public CCLayerMultiplex(CCAction inAction, CCAction outAction, CCLayer layer)
 {
     InitWithLayer(layer);
     m_InAction  = inAction;
     m_OutAction = outAction;
 }
コード例 #11
0
ファイル: TextInputTest.cs プロジェクト: Ratel13/cocos2d-xna
        // 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;
        }
コード例 #12
0
 public CCLayerMultiplex(CCAction inAction, CCAction outAction, params CCLayer[] layer)
 {
     InitWithLayers(layer);
     m_InAction = inAction;
     m_OutAction = outAction;
 }
コード例 #13
0
        // 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);
        }
コード例 #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;
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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");
            }
        }
コード例 #17
0
 public CCLayerMultiplex(CCAction inAction, CCAction outAction)
 {
     m_InAction  = inAction;
     m_OutAction = outAction;
 }