Esempio n. 1
0
        void onTouchMoved(CCTouch touch, CCEvent touchEvent)
        {
            CCPoint diff = touch.Delta;
            CCNode  node = GetChildByTag(kTagBox2DNode);

            node.Position = node.Position + diff;
        }
Esempio n. 2
0
        /**********************************************************************
         *********************************************************************/
        private bool OnTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            if (touch.Location.X > touchEvent.CurrentTarget.PositionX && touch.Location.X < (touchEvent.CurrentTarget.Position.X + 40.0f) && //40 because it's the width of the packages spriteframe
                touch.Location.Y > touchEvent.CurrentTarget.PositionY && touch.Location.Y < (touchEvent.CurrentTarget.PositionY + 50.0f)   //50 because it's the height of the packages spriteframe
                )
            {
                switch (touchCount)
                {
                case 0: Corrupt(); break;

                case 1: SlowDown();
                    if (OldPipelineProtocols.strategy == "Selective Repeat")
                    {
                        OldPipelineProtocolsScene.SlowDownPack(this, ((int)touch.Location.X - 20));
                    }
                    else
                    {
                        OldPipelineProtocolsScene2.SlowDownPack(this, ((int)touch.Location.X - 20));
                    }
                    break;

                case 2: SlowCorrupt(); break;

                case 3: Lost(); break;

                default: break;
                }
            }
            return(true);
        }
 void onTouchesBegan(List <CCTouch> touches, CCEvent touchEvent)
 {
     foreach (var it in touches)
     {
         CCTouch touch       = it;
         var     m_tBeginPos = touch.LocationOnScreen;
     }
 }
Esempio n. 4
0
        public override void TouchEnded(CCTouch touch)
        {
            float accel_filter = 0.1f;
            float ax           = ConvertTouchToNodeSpace(touch).X - ConvertToNodeSpace(touch.PreviousLocationInView).X;

            ax        /= 500;
            bird_vel.X = bird_vel.X * accel_filter + (float)ax * (1.0f - accel_filter) * 500.0f;
        }
Esempio n. 5
0
        //public override void TouchEnded(CCTouch touch)
        //{

        //}

        private void OnTouchEnded(CCTouch arg1, CCEvent arg2)
        {
            float accel_filter = 0.1f;
            float ax           = ConvertTouchToNodeSpace(arg1).X - ConvertToNodeSpace(arg1.PreviousLocationInView).X;

            ax        /= 500;
            bird_vel.X = bird_vel.X * accel_filter + (float)ax * (1.0f - accel_filter) * 500.0f;
        }
Esempio n. 6
0
 public override void TouchesBegan(List <CCTouch> pTouches)
 {
     foreach (var it in pTouches)
     {
         CCTouch touch       = it;
         var     m_tBeginPos = touch.Location;
     }
 }
Esempio n. 7
0
 public void HandlePress(CCTouch touch, Player player)
 {
     if (IsTouched(touch))
     {
         player.direction = "right";
         player.velocityX = 30;
     }
 }
            bool touchHits(CCTouch touch)
            {
                var location = touch.Location;

                var area = buttonSprite.BoundingBox;

                return(area.ContainsPoint(buttonSprite.WorldToParentspace(location)));
            }
Esempio n. 9
0
        internal CCPoint DefaultVelocityVectorFunction(CCTouch touch)
        {
            CCPoint scrollVelocity = new CCPoint(touch.Delta.X, touch.Delta.Y);
            CCPoint DiffOnScreen   = touch.LocationOnScreen - touch.PreviousLocationOnScreen;

            scrollVelocity *= (float)Math.Pow(DiffOnScreen.Length, 0.2);
            scrollVelocity *= 16;
            return(scrollVelocity);
        }
 private void OnTouchMoved(CCTouch touch, CCEvent arg2)
 {
     if (_selectedParticle != null && WithinGameArea(touch.Location))
     {
         _selectedParticle.Particle.Position = new Vector(touch.Location.X, touch.Location.Y);
         _selectedParticle.GraphicalPoint    = touch.Location;
         RedrawParticles();
     }
 }
Esempio n. 11
0
 public override void TouchesBegan(List <CCTouch> pTouches)
 {
     foreach (var it in pTouches)
     {
         CCTouch touch = it;
         m_tBeginPos = touch.LocationInView;
         m_tBeginPos = CCDirector.SharedDirector.ConvertToGl(m_tBeginPos);
     }
 }
Esempio n. 12
0
 public override void ccTouchesBegan(List <CCTouch> pTouches, CCEvent pEvent)
 {
     foreach (var it in pTouches)
     {
         CCTouch touch = it;
         m_tBeginPos = touch.locationInView(touch.view());
         m_tBeginPos = CCDirector.sharedDirector().convertToGL(m_tBeginPos);
     }
 }
Esempio n. 13
0
        public override bool TouchBegan(CCTouch touch)
        {
            CCPoint touchLocation = touch.Location;

            first    = ConvertToNodeSpace(touchLocation);
            isMoving = true;

            return(true);
        }
        void DetermineHorizontalRatio(List <CCTouch> touches)
        {
            CCTouch horizontalMovementTouch = null;

            if (horizontalMovementTouchId != -1)
            {
                foreach (var item in touches)
                {
                    if (item.Id == horizontalMovementTouchId)
                    {
                        horizontalMovementTouch = item;
                        break;
                    }
                }
            }

            if (horizontalMovementTouch == null)
            {
                // Couldn't find one or we have a -1 ID. Let's set
                // the ID to -1 to indicate we don't have a valid touch:
                horizontalMovementTouchId = -1;
            }

            if (horizontalMovementTouch == null)
            {
                // let's see if we can find one that is to the left of the screen
                foreach (var item in touches)
                {
                    if (item.Location.X < owner.ContentSize.Center.X)
                    {
                        horizontalMovementTouch   = item;
                        horizontalMovementTouchId = item.Id;
                    }
                }
            }

            if (horizontalMovementTouch != null)
            {
                float quarterWidth = owner.ContentSize.Width / 4;
                HorizontalRatio = (horizontalMovementTouch.Location.X - quarterWidth) / quarterWidth;

                HorizontalRatio = Math.Min(1, HorizontalRatio);
                HorizontalRatio = Math.Max(-1, HorizontalRatio);

                const float deadZone = .15f;
                if (Math.Abs(HorizontalRatio) < deadZone)
                {
                    HorizontalRatio = 0;
                }
            }
            else
            {
                // for emulator testing, we'll turn this off, but we need it on eventually on device:
//				HorizontalRatio = 0;
            }
        }
Esempio n. 15
0
        void onTouchesBegan(List <CCTouch> touches, CCEvent touchEvent)
        {
            CCTouch touch   = touches[0];
            CCNode  clipper = this.GetChildByTag(kTagClipperNode);
            CCPoint point   = clipper.Layer.ScreenToWorldspace(touch.LocationOnScreen);

            m_bScrolling = clipper.BoundingBoxTransformedToWorld.ContainsPoint(point);
            Console.WriteLine("Touched: " + point + "clipper.BB: " + clipper.BoundingBoxTransformedToWorld + " scrolling: " + m_bScrolling);
            m_lastPoint = point;
        }
Esempio n. 16
0
        bool onTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            CCPoint touchLocation = touch.LocationOnScreen;

            CCPoint nodePosition = Layer.ScreenToWorldspace(touchLocation);

            //    NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y);
            CCLog.Log("OnTouchBegan: " + nodePosition);
            return(m_test.MouseDown(new b2Vec2(nodePosition.X, nodePosition.Y)));
        }
Esempio n. 17
0
        public override bool IsPointInBounds(CCTouch touch)
        {
            var t1 = ScreenToWorldspace(touch.LocationOnScreen);

            var p1 = Position;

            var delta = t1 - p1;

            return(delta.Length < FontSize);
        }
Esempio n. 18
0
        public override void TouchesBegan(List <CCTouch> touches)
        {
            CCTouch touch   = touches[0];
            CCNode  clipper = this.GetChildByTag(kTagClipperNode);
            CCPoint point   = clipper.ConvertToNodeSpace(touch.Location);
            CCRect  rect    = new CCRect(0, 0, clipper.ContentSize.Width, clipper.ContentSize.Height);

            m_bScrolling = rect.ContainsPoint(point);
            m_lastPoint  = point;
        }
Esempio n. 19
0
 public override void TouchesMoved(List <CCTouch> touches)
 {
     foreach (var item in touches)
     {
         CCTouch    touch    = item;
         TouchPoint pTP      = s_dic[touch.Id];
         CCPoint    location = touch.Location;
         pTP.SetTouchPos(location);
     }
 }
Esempio n. 20
0
        private void HandleInput(System.Collections.Generic.List <CCTouch> touches, CCEvent touchEvent)
        {
            if (touches.Count > 0)
            {
                CCTouch firstTouch = touches[0];

                this.PositionX = firstTouch.Location.X;
                this.PositionY = firstTouch.Location.Y;
            }
        }
Esempio n. 21
0
            void OnTouchEnded(CCTouch touch, CCEvent touchEvent)
            {
                bool hits = touchHits(touch);

                if (hits && Triggered != null)
                {
                    Triggered(this, EventArgs.Empty);
                }
                scaleButtonTo(1);
            }
Esempio n. 22
0
 public void HandlePress(CCTouch touch, Player player)
 {
     if (IsTouched(touch) && player.isStanding)
     {
         player.isStanding = false;
         player.velocityY  = 110;
         this.AssignAnimation(buttonPress);
         currentAnimation = new Animation();
     }
 }
Esempio n. 23
0
 public override void TouchesEnded(List <CCTouch> touches)
 {
     foreach (var item in touches)
     {
         CCTouch    touch = item;
         TouchPoint pTP   = s_dic[touch.Id];
         RemoveChild(pTP, true);
         s_dic.Remove(touch.Id);
     }
 }
Esempio n. 24
0
 void onTouchesEnded(List <CCTouch> touches, CCEvent touchEvent)
 {
     foreach (var item in touches)
     {
         CCTouch    touch = item;
         TouchPoint pTP   = s_dic[touch.Id];
         RemoveChild(pTP, true);
         s_dic.Remove(touch.Id);
     }
 }
Esempio n. 25
0
        void OnTouchesBegan(List <CCTouch> touches, CCEvent touchEvent)
        {
            if (touches.Count > 0)
            {
                CCTouch touch         = touches [0];
                CCPoint touchLocation = touch.Location;

                MoveShipTo(new CCPoint(ship.Position.X, touchLocation.Y));
            }
        }
Esempio n. 26
0
 public void HandleSingleTouchEnded(CCTouch touch)
 {
     _isTouchDown = false;
     if (!_isEnabled)
     {
         return;
     }
     if (!Enabled)
     {
         return;
     }
     if (_hitRect.Contains(UnityEngine.Camera.main.ScreenToWorldPoint(touch.Position)))
     {
         if (SignalRelease != null)
         {
             SignalRelease(this);
         }
         if (_overElement != null)
         {
             if (!_supportsOver)
             {
                 GetComponent <SpriteRenderer>().sprite = _overElement;
                 if (_shouldUseCustomColors)
                 {
                     GetComponent <SpriteRenderer>().color = _overColor;
                 }
             }
             else
             {
                 GetComponent <SpriteRenderer>().sprite = _upElement;
                 if (_shouldUseCustomColors)
                 {
                     GetComponent <SpriteRenderer>().color = _upColor;
                 }
             }
             _supportsOver = !_supportsOver;
         }
         else
         {
             GetComponent <SpriteRenderer>().sprite = _upElement;
             if (_shouldUseCustomColors)
             {
                 GetComponent <SpriteRenderer>().color = _upColor;
             }
         }
     }
     else
     {
         if (SignalReleaseOutside != null)
         {
             SignalReleaseOutside(this);
         }
     }
     transform.localScale = new Vector3(xsize, ysize);
 }
Esempio n. 27
0
 void onTouchesMoved(List <CCTouch> touches, CCEvent touchEvent)
 {
     foreach (var item in touches)
     {
         CCTouch    touch    = item;
         TouchPoint pTP      = s_dic[touch.Id];
         CCPoint    location = touch.LocationOnScreen;
         location = Layer.ScreenToWorldspace(location);
         pTP.SetTouchPos(location);
     }
 }
Esempio n. 28
0
        void onTouchesBegan(List <CCTouch> pTouches, CCEvent touchEvent)
        {
            CCTouch touch    = pTouches[0];
            CCPoint location = Layer.ScreenToWorldspace(touch.LocationOnScreen);

            if (arrows.BoundingBox.ContainsPoint(location))
            {
                drag = true;
                arrowsBar.Visible = true;
            }
        }
Esempio n. 29
0
        public override void TouchesBegan(List <CCTouch> pTouches)
        {
            CCTouch touch    = pTouches[0];
            CCPoint location = touch.LocationInView;

            if (m_pArrowsShouldRetain.BoundingBox.ContainsPoint(location))
            {
                m_drag = true;
                m_pArrowsBarShouldRetain.Visible = true;
            }
        }
        void onTouchesBegan(List <CCTouch> pTouches, CCEvent touchEvent)
        {
            CCTouch touch    = pTouches[0];
            CCPoint location = touch.Location;

            if (arrows.BoundingBox.ContainsPoint(location))
            {
                drag = true;
                arrowsBar.Visible = true;
            }
        }