Пример #1
0
        // actions

        /// <summary>
        /// Adds an action with a target. 
        ///  If the target is already present, then the action will be added to the existing target.
        ///  If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target.
        ///  When the target is paused, the queued actions won't be 'ticked'.
        /// </summary>
        public void addAction(CCAction action, CCNode target, bool paused)
        {
            Debug.Assert(action != null);
            Debug.Assert(target != null);

            tHashElement element = null;
            if (!m_pTargets.ContainsKey(target))
            {
                element = new tHashElement();
                element.paused = paused;
                element.target = target;
                m_pTargets.Add(target, element);
            }
            else
            {
                element = m_pTargets[target];
            }

            actionAllocWithHashElement(element);

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

            action.startWithTarget(target);
        }
Пример #2
0
        /// <summary>
        /// creates the action with an inner action that has the amplitude property, and a duration time
        /// </summary>
        public static CCAccelAmplitude actionWithAction(CCAction pAction, float duration)
        {
            CCAccelAmplitude pRet = new CCAccelAmplitude();
            if (pRet.initWithAction(pAction, duration))
            {
                return pRet;
            }

            return null;
        }
Пример #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
        /// <summary>
        /// initializes the action with an inner action that has the amplitude property, and a duration time
        /// </summary>
        public bool initWithAction(CCAction pAction, float duration)
        {
            if (base.initWithDuration(duration))
            {
                m_fRate = 1.0f;
                m_pOther = pAction as CCActionInterval;

                return true;
            }

            return false;
        }
Пример #5
0
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone tmpZone = zone;
            CCAction ret = null;
            if (tmpZone != null && tmpZone.m_pCopyObject != null)
            {
                ret = (CCAction)tmpZone.m_pCopyObject;
            }
            else
            {
                ret = new CCAction();
            }

            ret.m_nTag = m_nTag;
            return ret;
        }
Пример #6
0
 public static void AsyncActionCallBack(CCAction p_Action,EventHandler CallBack)
 {
     System.Threading.ThreadPool.QueueUserWorkItem
         ((obj) =>
         {
             while (true)
             {
                 System.Threading.Thread.Sleep(100);
                 if (p_Action.isDone())
                 {
                     CallBack.Invoke(null,new EventArgs());
                     break;
                 }
             }
         });
 }
        /// <summary>
        /// creates the action with an inner action that has the amplitude property, and a duration time
        /// </summary>
        /// <param name="pAction"></param>
        /// <param name="duration"></param>
        /// <returns></returns>
        public static CCAccelAmplitude actionWithAction(CCAction pAction, float duration)
        {
            CCAccelAmplitude pRet = new CCAccelAmplitude();

            if (pRet != null)
            {
                if (pRet.initWithAction(pAction, duration))
                {
                    //pRet->autorelease();
                }
                else
                {
                    //CC_SAFE_DELETE(pRet);
                }
            }

            return pRet;
        }
Пример #8
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);
        }
Пример #9
0
 public CCDeccelAmplitude(CCAction pAction, float duration)
     : base(duration)
 {
     InitWithAction(pAction, duration);
 }
Пример #10
0
        // CCLayer
        public override void onEnter()
        {
            base.onEnter();

            m_nCharLimit = 12;

            m_pTextFieldAction = CCRepeatForever.actionWithAction(
                (CCActionInterval)CCSequence.actions(
                    CCFadeOut.actionWithDuration(0.25f),
                    CCFadeIn.actionWithDuration(0.25f)));
            //m_pTextFieldAction->retain();
            m_bAction = false;

            // add CCTextFieldTTF
            CCSize s = CCDirector.sharedDirector().getWinSize();

            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;
        }
Пример #11
0
 /// <summary>
 /// Removes an action from the running action list
 /// </summary>
 public void stopAction(CCAction action)
 {
     CCActionManager.sharedManager().removeAction(action);
 }
Пример #12
0
 /// <summary>
 /// Executes an action, and returns the action that is executed.
 /// The node becomes the action's target.
 /// @warning Starting from v0.8 actions don't retain their target anymore.
 /// @since v0.7.1
 /// @return 
 /// </summary>
 /// <returns>An Action pointer</returns>
 public CCAction runAction(CCAction action)
 {
     Debug.Assert(action != null, "Argument must be non-nil");
     CCActionManager.sharedManager().addAction(action, this, !m_bIsRunning);
     return action;
 }
Пример #13
0
 public void stopAction(CCAction action)
 {
     CCActionManager.sharedManager().removeAction(action);
 }
Пример #14
0
 //播放循环动画的统一方法
 private void RunAnimateAction_RepeatForever(CCAnimate action)
 {
     currentAnimateActionStop();
     _currentAnimateAction = runAction(CCRepeatForever.actionWithAction(action));
 }
Пример #15
0
        public void RemoveAction(CCAction action)
        {
            if (action == 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");
            }
        }
Пример #16
0
 public static CCAccelAmplitude Create(CCAction pAction, float duration)
 {
     var pRet = new CCAccelAmplitude();
     pRet.InitWithAction(pAction, duration);
     return pRet;
 }
Пример #17
0
 public CCAction RunAction(CCAction action)
 {
     Debug.Assert(action != null, "Argument must be non-nil");
     m_pActionManager.AddAction(action, this, !m_bIsRunning);
     return action;
 }
Пример #18
0
 public void StopAction(CCAction action)
 {
     m_pActionManager.RemoveAction(action);
 }
Пример #19
0
        /// <summary>
        /// Removes an action given an action reference.
        /// </summary>
        public void removeAction(CCAction action)
        {
            if (action == null)
            {
                return;
            }

            CCObject target = action.originalTarget;

            if (m_pTargets.ContainsKey(target))
            {
                tHashElement element = m_pTargets[target];
                int i = element.actions.IndexOf(action);

                if (i != -1)
                {
                    removeActionAtIndex(i, element);
                }
            }
            else
            {
                CCLog.Log("cocos2d: removeAction: Target not found");
            }
        }
Пример #20
0
 public CCAction runAction(CCAction action)
 {
     CCActionManager.sharedManager().addAction(action, this, !this.m_bIsRunning);
     return(action);
 }