public override void ccTouchEnded(CCTouch pTouch, CCEvent pEvent)
        {
            if (m_pTrackNode != null)
            {
                return;
            }

            CCPoint endPos = pTouch.locationInView(pTouch.view());
            endPos = CCDirector.sharedDirector().convertToGL(endPos);

            float delta = 5.0f;
            if (Math.Abs(endPos.x - m_beginPos.x) > delta
                || Math.Abs(endPos.y - m_beginPos.y) > delta)
            {
                // not click
                m_beginPos.x = m_beginPos.y = -1;
                return;
            }

            // decide the trackNode is clicked.
            CCRect rect;
            CCPoint point = convertTouchToNodeSpaceAR(pTouch);
            Debug.WriteLine("KeyboardNotificationLayer:clickedAt(%f,%f)", point.x, point.y);

            rect = TextInputTestScene.getRect(m_pTrackNode);
            Debug.WriteLine("KeyboardNotificationLayer:TrackNode at(origin:%f,%f, size:%f,%f)",
                rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);

            this.onClickTrackNode(CCRect.CCRectContainsPoint(rect, point));
            Debug.WriteLine("----------------------------------");
        }
 // CCLayer
 public override bool ccTouchBegan(CCTouch pTouch, CCEvent pEvent)
 {
     Debug.WriteLine("++++++++++++++++++++++++++++++++++++++++++++");
     m_beginPos = pTouch.locationInView(pTouch.view());
     m_beginPos = CCDirector.sharedDirector().convertToGL(m_beginPos);
     return true;
 }
 public void excuteScriptTouchHandler(int eventType, CCTouch pTouch)
 {
     if (m_pEventTypeFuncMap != null && CCScriptEngineManager.sharedScriptEngineManager().ScriptEngine != null)
     {
         CCScriptEngineManager.sharedScriptEngineManager().ScriptEngine.executeTouchEvent((m_pEventTypeFuncMap)[eventType].ToString(),
                                                                                          pTouch);
     }
 }
Beispiel #4
0
 public override void ccTouchCancelled(CCTouch touch, CCEvent ccevent)
 {
     if (this.m_pSelectedItem != null)
     {
         this.m_pSelectedItem.unselected();
     }
     this.m_eState = tCCMenuState.kCCMenuStateWaiting;
 }
 public void excuteScriptTouchHandler(int eventType, CCTouch pTouch)
 {
     if (m_pEventTypeFuncMap != null && CCScriptEngineManager.sharedScriptEngineManager().ScriptEngine != null)
     {
         CCScriptEngineManager.sharedScriptEngineManager().ScriptEngine.executeTouchEvent((m_pEventTypeFuncMap)[eventType].ToString(),
                                                                                                  pTouch);
     }
 }
Beispiel #6
0
        public virtual bool ccTouchBegan(CCTouch touch, CCEvent eventer)
        {
            if (m_state != PaddleState.kPaddleStateUngrabbed) return false;
            if (!containsTouchLocation(touch)) return false;

            m_state = PaddleState.kPaddleStateGrabbed;
            return true;
        }
 public void ExcuteScriptTouchHandler(int eventType, CCTouch pTouch)
 {
     if (m_pEventTypeFuncMap != null && CCScriptEngineManager.SharedScriptEngineManager.ScriptEngine != null)
     {
         CCScriptEngineManager.SharedScriptEngineManager.ScriptEngine.ExecuteTouchEvent((m_pEventTypeFuncMap)[eventType],
                                                                                          pTouch);
     }
 }
 public void updateSize(CCTouch touch)
 {
     CCPoint touchLocation = touch.locationInView(touch.view());
     touchLocation = CCDirector.sharedDirector().convertToGL(touchLocation);
     CCSize s = CCDirector.sharedDirector().getWinSize();
     CCSize newSize = new CCSize(Math.Abs(touchLocation.x - s.width / 2) * 2, Math.Abs(touchLocation.y - s.height / 2) * 2);
     CCLayerColor l = (CCLayerColor)getChildByTag(kTagLayer);
     l.contentSize = newSize;
 }
        public virtual void ccTouchEnded(CCTouch touch, CCEvent eventer)
        {
            CCPoint touchPoint = touch.locationInView(touch.view());
            CCPoint convertedLocation = CCDirector.sharedDirector().convertToGL(touchPoint);

            //执行运动
            CCActionInterval move = CCMoveTo.actionWithDuration(3, convertedLocation);
            CCActionInterval move_ease_inout = CCEaseInOut.actionWithAction(move);//ease缓冲
            base.runAction(move_ease_inout);
        }
Beispiel #10
0
        public override bool TouchBegan(CCTouch touch, CCEvent e)
        {
            CCPoint touchLocation = touch.Location;

            CCPoint nodePosition = ConvertToNodeSpace(touchLocation);
            //    NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y);

            m_test.MouseDown(new Vector2(nodePosition.X, nodePosition.Y));

            return true;
        }
Beispiel #11
0
        public override void ccTouchCancelled(CCTouch touch, CCEvent ccevent)
        {
            Debug.Assert(m_eState == tCCMenuState.kCCMenuStateTrackingTouch, "[Menu ccTouchCancelled] -- invalid state");

            if (m_pSelectedItem != null)
            {
                m_pSelectedItem.unselected();
            }

            m_eState = tCCMenuState.kCCMenuStateWaiting;
        }
Beispiel #12
0
 public void ccTouchEnded(CCTouch pTouch, CCEvent pEvent)
 {
     CCPoint point = pTouch.locationInView(0);
     CCPoint newPoint = CCDirector.sharedDirector().convertToGL(point);
     CCPoint rePoint = GetGroundPosition(newPoint);
     if ((int)rePoint.x < Map.Height &&
         (int)rePoint.y < Map.Width &&
         (role.Col != (int)rePoint.y || role.Row != (int)rePoint.x))
     {
         map.ChangeToWall((int)rePoint.x, (int)rePoint.y);
     }
     role.GetPathNodeList();
 }
Beispiel #13
0
        public override void TouchMoved(CCTouch touch, CCEvent event_)
        {
            CCPoint touchLocation = touch.LocationInView;
            CCPoint prevLocation = touch.PreviousLocationInView;

            touchLocation = CCDirector.SharedDirector.ConvertToGl(touchLocation);
            prevLocation = CCDirector.SharedDirector.ConvertToGl(prevLocation);

            CCPoint diff = touchLocation - prevLocation;

            CCNode node = GetChildByTag(kTagTileMap); // (int) KTag.kTagNode);
            CCPoint currentPos = node.Position;
            node.Position = currentPos + diff;
        }
Beispiel #14
0
        public override void ccTouchMoved(CCTouch touch, CCEvent parmevent)
        {
            CCPoint touchLocation = touch.locationInView(touch.view());
            CCPoint prevLocation = touch.previousLocationInView(touch.view());

            touchLocation = CCDirector.sharedDirector().convertToGL(touchLocation);
            prevLocation = CCDirector.sharedDirector().convertToGL(prevLocation);

            CCPoint diff = new CCPoint(touchLocation.x - prevLocation.x, touchLocation.y - prevLocation.y);

            CCNode node = getChildByTag(1);
            CCPoint currentPos = node.position;
            node.position = new CCPoint(currentPos.x + diff.x, currentPos.y + diff.y);
        }
Beispiel #15
0
        public virtual void ccTouchMoved(CCTouch touch, CCEvent eventer)
        {
            // If it weren't for the TouchDispatcher, you would need to keep a reference
            // to the touch from touchBegan and check that the current touch is the same
            // as that one.
            // Actually, it would be even more complicated since in the Cocos dispatcher
            // you get CCSets instead of 1 UITouch, so you'd need to loop through the set
            // in each touchXXX method.

            Debug.Assert(m_state == PaddleState.kPaddleStateGrabbed, "Paddle - Unexpected state!");

            CCPoint touchPoint = touch.locationInView(touch.view());
            touchPoint = CCDirector.sharedDirector().convertToGL(touchPoint);

            base.position = new CCPoint(touchPoint.x, base.position.y);
        }
Beispiel #16
0
        public override void ccTouchMoved(CCTouch touch, CCEvent ccevent)
        {
            CCMenuItem cCMenuItem = this.itemForTouch(touch);

            if (cCMenuItem != this.m_pSelectedItem)
            {
                if (this.m_pSelectedItem != null)
                {
                    this.m_pSelectedItem.unselected();
                }
                this.m_pSelectedItem = cCMenuItem;
                if (this.m_pSelectedItem != null)
                {
                    this.m_pSelectedItem.selected();
                }
            }
        }
Beispiel #17
0
        public override void ccTouchMoved(CCTouch touch, CCEvent ccevent)
        {
            Debug.Assert(m_eState == tCCMenuState.kCCMenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state");

            CCMenuItem currentItem = this.itemForTouch(touch);

            if (currentItem != m_pSelectedItem)
            {
                if (m_pSelectedItem != null)
                {
                    m_pSelectedItem.unselected();
                }

                m_pSelectedItem = currentItem;

                if (m_pSelectedItem != null)
                {
                    m_pSelectedItem.selected();
                }
            }
        }
Beispiel #18
0
 public override bool ccTouchBegan(CCTouch touch, CCEvent ccevent)
 {
     if (this.m_eState != tCCMenuState.kCCMenuStateWaiting || !this.m_bIsVisible)
     {
         return(false);
     }
     for (CCNode i = this.m_pParent; i != null; i = i.parent)
     {
         if (!i.visible)
         {
             return(false);
         }
     }
     this.m_pSelectedItem = this.itemForTouch(touch);
     if (this.m_pSelectedItem == null)
     {
         return(false);
     }
     this.m_eState = tCCMenuState.kCCMenuStateTrackingTouch;
     this.m_pSelectedItem.selected();
     return(true);
 }
Beispiel #19
0
        protected CCMenuItem itemForTouch(CCTouch touch)
        {
            CCMenuItem cCMenuItem;
            CCPoint    gL = touch.locationInView(touch.view());

            gL = CCDirector.sharedDirector().convertToGL(gL);
            if (this.m_pChildren != null && this.m_pChildren.Count > 0)
            {
                List <CCNode> .Enumerator enumerator = this.m_pChildren.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        CCNode current = enumerator.Current;
                        if (current == null || !current.visible || !((CCMenuItem)current).Enabled)
                        {
                            continue;
                        }
                        CCPoint nodeSpace = current.convertToNodeSpace(gL);
                        CCRect  zero      = ((CCMenuItem)current).rect();
                        zero.origin = CCPoint.Zero;
                        if (!CCRect.CCRectContainsPoint(zero, nodeSpace))
                        {
                            continue;
                        }
                        cCMenuItem = (CCMenuItem)current;
                        return(cCMenuItem);
                    }
                    return(null);
                }
                finally
                {
                    ((IDisposable)enumerator).Dispose();
                }
                return(cCMenuItem);
            }
            return(null);
        }
Beispiel #20
0
 /// <summary>
 /// �����ʼ
 /// </summary>
 /// <param name="pTouch"></param>
 /// <param name="pEvent"></param>
 /// <returns></returns>
 public bool ccTouchBegan(CCTouch pTouch, CCEvent pEvent)
 {
     if (isBirdAlive && birdBody.Position.y < AppDelegate.screenSize.height / PTM_RATIO)
     {
         birdBody.LinearVelocity = new b2Vec2(0, 8);
         ((CCSprite)(birdBody.UserData)).rotation = -30;
         if (!flyRepeatAction.isDone())
         {
             ((CCSprite)(birdBody.UserData)).stopActionByTag(0);
         }
         ((CCSprite)(birdBody.UserData)).runAction(flyRepeatAction);
         SimpleAudioEngine.sharedEngine().playEffect(@"musics/sfx_wing");
     }
     return true;
 }
Beispiel #21
0
 public void ccTouchCancelled(CCTouch pTouch, CCEvent pEvent)
 {
 }
Beispiel #22
0
 public override void TouchMoved(CCTouch touch, CCEvent pEvent)
 {
 }
Beispiel #23
0
 /// <summary>
 /// converts a CCTouch (world coordinates) into a local coordiante. This method is AR (Anchor Relative).
 /// @since v0.7.1
 /// </summary>
 public CCPoint convertTouchToNodeSpaceAR(CCTouch touch)
 {
     CCPoint point = touch.locationInView(touch.view());
     point = CCDirector.sharedDirector().convertToGL(point);
     return this.convertToNodeSpaceAR(point);
 }
Beispiel #24
0
        protected CCMenuItem itemForTouch(CCTouch touch)
        {
            //XNA point
            CCPoint touchLocation = touch.locationInView(touch.view());
            //cocos2d point
            touchLocation = CCDirector.sharedDirector().convertToGL(touchLocation);

            if (m_pChildren != null && m_pChildren.Count > 0)
            {
                foreach (var pChild in m_pChildren)
                {
                    if (pChild != null && pChild.visible && ((CCMenuItem)pChild).Enabled)
                    {
                        CCPoint local = pChild.convertToNodeSpace(touchLocation);
                        CCRect r = ((CCMenuItem)pChild).rect();
                        r.origin = CCPoint.Zero;

                        if (CCRect.CCRectContainsPoint(r, local))
                        {
                            return (CCMenuItem)pChild;
                        }
                    }
                }
            }

            return null;
        }
 // functions for excute touch event
 public virtual bool executeTouchEvent(string pszFuncName, CCTouch pTouch)
 {
     return(false);
 }
Beispiel #26
0
 public virtual void ccTouchMoved(CCTouch touch, CCEvent event_)
 {
 }
Beispiel #27
0
        public override void ccTouchEnded(CCTouch touch, CCEvent ccevent)
        {
            Debug.Assert(m_eState == tCCMenuState.kCCMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state");

            if (m_pSelectedItem != null)
            {
                m_pSelectedItem.unselected();
                m_pSelectedItem.activate();
            }

            m_eState = tCCMenuState.kCCMenuStateWaiting;
        }
Beispiel #28
0
 public virtual bool ccTouchBegan(CCTouch touch, CCEvent event_)
 {
     // Debug.Assert(false, "Layer#ccTouchBegan override me");
     return true;
 }
Beispiel #29
0
 public void ccTouchEnded(CCTouch pTouch, CCEvent pEvent)
 {
 }
Beispiel #30
0
 public virtual bool ccTouchBegan(CCTouch touch, CCEvent event_)
 {
     return(true);
 }
Beispiel #31
0
 public override void TouchEnded(CCTouch touch, CCEvent e)
 {
 }
Beispiel #32
0
 public virtual void ccTouchEnded(CCTouch touch, CCEvent eventer)
 {
     Debug.Assert(m_state == PaddleState.kPaddleStateGrabbed, "Paddle - Unexpected state!");
     m_state = PaddleState.kPaddleStateUngrabbed;
 }
Beispiel #33
0
 public void ccTouchMoved(CCTouch pTouch, CCEvent pEvent)
 {
 }
Beispiel #34
0
 public virtual bool ccTouchBegan(CCTouch touch, CCEvent event_)
 {
     // Debug.Assert(false, "Layer#ccTouchBegan override me");
     return(true);
 }
Beispiel #35
0
 public virtual void ccTouchCancelled(CCTouch touch, CCEvent event_)
 {
 }
Beispiel #36
0
 public virtual void ccTouchEnded(CCTouch touch, CCEvent event_)
 {
 }
Beispiel #37
0
        /// <summary>
        /// For phone event handle functions
        /// </summary>
        public override bool ccTouchBegan(CCTouch touch, CCEvent ccevent)
        {
            if (m_eState != tCCMenuState.kCCMenuStateWaiting || !m_bIsVisible)
            {
                return false;
            }

            for (CCNode c = this.m_pParent; c != null; c = c.parent)
            {
                if (c.visible == false)
                {
                    return false;
                }
            }

            m_pSelectedItem = this.itemForTouch(touch);

            if (m_pSelectedItem != null)
            {
                m_eState = tCCMenuState.kCCMenuStateTrackingTouch;
                m_pSelectedItem.selected();

                return true;
            }

            return false;
        }
Beispiel #38
0
 public virtual void ccTouchCancelled(CCTouch touch, CCEvent event_)
 {
 }
Beispiel #39
0
        public override void ccTouchMoved(CCTouch touch, CCEvent ccevent)
        {
            Debug.Assert(m_eState == tCCMenuState.kCCMenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state");

            CCMenuItem currentItem = this.itemForTouch(touch);

            if (currentItem != m_pSelectedItem)
            {
                if (m_pSelectedItem != null)
                {
                    m_pSelectedItem.unselected();
                }

                m_pSelectedItem = currentItem;

                if (m_pSelectedItem != null)
                {
                    m_pSelectedItem.selected();
                }
            }
        }
Beispiel #40
0
 public override bool TouchBegan(CCTouch touch, CCEvent pEvent)
 {
     return true;
 }
Beispiel #41
0
 public override void TouchMoved(CCTouch touch, CCEvent e)
 {
     CCPoint diff = touch.Delta;
     CCNode node = GetChildByTag(kTagTileMap);
     CCPoint currentPos = node.Position;
     node.Position = currentPos + diff;
 }
Beispiel #42
0
 public override void TouchCancelled(CCTouch touch, CCEvent pEvent)
 {
 }