当前位置: 首页>>代码示例>>C#>>正文


C# MonoTouch.ToArray方法代码示例

本文整理汇总了C#中MonoTouch.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# MonoTouch.ToArray方法的具体用法?C# MonoTouch.ToArray怎么用?C# MonoTouch.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MonoTouch的用法示例。


在下文中一共展示了MonoTouch.ToArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TouchesBegan

 public override void TouchesBegan(MonoTouch.Foundation.NSSet touches, UIEvent evt)
 {
     var allTouches = touches.ToArray<UITouch>();
     var count = allTouches.Length;
     if(count > 0)
     {
         Loc1 = allTouches[0].LocationInView(this);
     }
     if(count > 1)
     {
         Loc2 = allTouches[1].LocationInView(this);
     }
     SetNeedsDisplay();
 }
开发者ID:lobrien,项目名称:iPhone-Developer-s-Cookbook-in-Monotouch,代码行数:14,代码来源:MultiTouchView.cs

示例2: TouchesMoved

        internal void TouchesMoved( MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e,GameWindow window)
        {
            UITouch []touchesArray = touches.ToArray<UITouch>();
                foreach(UITouch touch in touchesArray)
                {
                    Vector2 location = new Vector2(touch.LocationInView(touch.View));
                    location = window.GetOffsetPosition(location,false);

                    var oldItem = GetTouchesObject(touch);
                    // Check if touch any button
                    bool hitInButton = false;
                    if (Visible)
                    {
                        if(oldItem != null && oldItem is ButtonDefinition)
                        {
                            hitInButton |= UpdateButton((ButtonDefinition)oldItem,location);
                        }
                        if(!hitInButton)
                            foreach(ButtonDefinition button in _buttonsDefinitions)
                            {
                                hitInButton |= UpdateButton (button, location);
                                if(hitInButton)
                                {
                                    UpdateTouch(touch,button);
                                    continue;
                                }
                            }
                    }

                    if (!hitInButton)
                    {
                        if(oldItem != null && oldItem == _leftThumbDefinition)
                        {
                            Vector2 movement = location - LeftThumbStickDefinition.InitialHit;
                            if(movement.X > 20)
                                movement.X = 20;
                            else if(movement.X < -20)
                                movement.X = -20;

                            if(movement.Y > 20)
                                movement.Y = 20;
                            else if(movement.Y < -20)
                                movement.Y = -20;
                            _leftThumbDefinition.Offset = movement;
                            _leftStick = new Vector2(movement.X / 20,movement.Y / -20);
                        }
                        else if (Visible && (_leftThumbDefinition != null) && (CheckThumbStickHit(_leftThumbDefinition,location)))
                        {
                            Vector2 movement = location - LeftThumbStickDefinition.InitialHit;

                            UpdateTouch(touch,_leftThumbDefinition);
                            LeftThumbStickDefinition.InitialHit = location;

                            // Keep the stick in the "hole"
                            float radius = (movement.X*movement.X) + (movement.Y*movement.Y);

                        if (radius <= _thumbStickRadius)
                            {
                                _leftThumbDefinition.Offset = movement;
                                _leftStick = new Vector2(movement.X / 20,movement.Y / -20);
                            }
                        }
                        else
                        {
                            // reset left thumbstick
                            if (_leftThumbDefinition != null)
                            {
                                _leftThumbDefinition.Offset = Vector2.Zero;
                                _leftStick = Vector2.Zero;
                            }

                            if(oldItem != null && oldItem == _rightThumbDefinition)
                            {
                                Vector2 movement = location - _rightThumbDefinition.InitialHit;
                                _rightThumbDefinition.Offset = movement;
                                _rightStick = new Vector2(movement.X / 20,movement.Y / -20);
                            }
                            else if (Visible && (_rightThumbDefinition != null) && (CheckThumbStickHit(_rightThumbDefinition,location)))
                            {
                                Vector2 movement = location - _rightThumbDefinition.InitialHit;

                                // Keep the stick in the "hole"
                                float radius = (movement.X*movement.X) + (movement.Y*movement.Y);
                                if (radius <= _thumbStickRadius)
                                {
                                    _rightThumbDefinition.Offset = movement;
                                    _rightStick = new Vector2(movement.X / 20,movement.Y / -20);
                                }
                            }
                            else
                            {
                                // reset right thumbstick
                                if (_rightThumbDefinition != null)
                                {
                                    _rightThumbDefinition.Offset = Vector2.Zero;
                                    _rightStick = Vector2.Zero;
                                }

                                // Handle the mouse
                                Mouse.State.X = (int) location.X;
//.........这里部分代码省略.........
开发者ID:scottmm,项目名称:MonoGame,代码行数:101,代码来源:GamePad.cs

示例3: TouchesEnded

 internal void TouchesEnded( MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e, GameWindow window)
 {
     UITouch []touchesArray = touches.ToArray<UITouch>();
         foreach(UITouch touch in touchesArray)
         {
             Vector2 location = new Vector2(touch.LocationInView(touch.View).X, touch.LocationInView(touch.View).Y);
             location = window.GetOffsetPosition(location,false);
             // Check where is the touch
             if (Visible)
             {
                 var oldItem = GetTouchesObject(touch);
                 if(oldItem == null)
                     continue;
                 if(oldItem is ButtonDefinition)
                 {
                     ButtonDefinition button = (ButtonDefinition)oldItem;
                     if  (CheckButtonHit(button, location))
                     {
                         _buttons &= ~(int)button.Type;
                     }
                 }
                 else if(oldItem  == _leftThumbDefinition)
                 {
                     LeftThumbStickDefinition.Offset = Vector2.Zero;
                     _leftStick = Vector2.Zero;
                 }
                 else if(oldItem == _rightThumbDefinition)
                 {
                     _rightThumbDefinition.Offset = Vector2.Zero;
                     _rightStick = Vector2.Zero;
                 }
                 RemoveTouch(touch);
             }
         }
         Reset();
 }
开发者ID:scottmm,项目名称:MonoGame,代码行数:36,代码来源:GamePad.cs

示例4: TouchesBegan

        internal void TouchesBegan( MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e, GameWindow window)
        {
            // Reset State
                //Reset();

                // Check where is the touch
                UITouch []touchesArray = touches.ToArray<UITouch>();
                foreach(UITouch touch in touchesArray)
                {
                    Vector2 location = new Vector2(touch.LocationInView(touch.View));
                    location = window.GetOffsetPosition(location,false);
                    // Check where is the touch
                    bool hitInButton = false;

                    if (Visible)
                    {
                        foreach(ButtonDefinition button in _buttonsDefinitions)
                        {
                            hitInButton |= UpdateButton (button, location);
                            UpdateTouch(touch,button);
                        }
                    }
                    if (!hitInButton)
                    {
                        // check the left thumbstick
                        if (Visible &&  (_leftThumbDefinition != null) && (CheckThumbStickHit(_leftThumbDefinition,location)))
                        {
                            _leftThumbDefinition.InitialHit = location;
                            UpdateTouch(touch,_leftThumbDefinition);
                        }
                        else
                        {
                            // check the right thumbstick
                            if (Visible && (_rightThumbDefinition != null) && (CheckThumbStickHit(_rightThumbDefinition,location)))
                            {
                                _rightThumbDefinition.InitialHit = location;
                                UpdateTouch(touch,_rightThumbDefinition);
                            }
                            else // Handle mouse
                            {
                                Mouse.State.X = (int) location.X;
                                Mouse.State.Y = (int) location.Y;
                            }
                        }

                    }
                }
        }
开发者ID:scottmm,项目名称:MonoGame,代码行数:48,代码来源:GamePad.cs

示例5: TouchesMoved

        internal void TouchesMoved( MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            UITouch []touchesArray = touches.ToArray<UITouch>();
            foreach(UITouch touch in touchesArray)
            {
                Vector2 location = new Vector2(touch.LocationInView(touch.View));
                // Check if touch any button
                bool hitInButton = false;
                if (Visible)
                {
                    foreach(ButtonDefinition button in _buttonsDefinitions)
                    {
                        hitInButton |= UpdateButton (button, location);
                    }
                }

                if (!hitInButton)
                {
                    if (Visible && (_leftThumbDefinition != null) && (CheckThumbStickHit(_leftThumbDefinition,location)))
                    {
                        Vector2 movement = location - LeftThumbStickDefinition.InitialHit;

                        // Keep the stick in the "hole"
                        float radius = (movement.X*movement.X) + (movement.Y*movement.Y);

                        if (radius <= _thumbStickRadius)
                        {
                            _leftThumbDefinition.Offset = movement;
                            _leftStick = new Vector2(movement.X / 20,movement.Y / -20);
                        }
                    }
                    else
                    {
                        // reset left thumbstick
                        if (_leftThumbDefinition != null)
                        {
                            _leftThumbDefinition.Offset = Vector2.Zero;
                            _leftStick = Vector2.Zero;
                        }

                        if (Visible && (_rightThumbDefinition != null) && (CheckThumbStickHit(_rightThumbDefinition,location)))
                        {
                            Vector2 movement = location - _rightThumbDefinition.InitialHit;

                            // Keep the stick in the "hole"
                            float radius = (movement.X*movement.X) + (movement.Y*movement.Y);

                            if (radius <= _thumbStickRadius)
                            {
                                _rightThumbDefinition.Offset = movement;
                                _rightStick = new Vector2(movement.X / 20,movement.Y / -20);
                            }
                        }
                        else
                        {
                            // reset right thumbstick
                            if (_rightThumbDefinition != null)
                            {
                                _rightThumbDefinition.Offset = Vector2.Zero;
                                _rightStick = Vector2.Zero;
                            }

                            // Handle the mouse
                            Mouse.SetPosition( (int) location.X, (int) location.Y);
                        }
                    }
                }
            }
        }
开发者ID:QHebert,项目名称:monogame,代码行数:69,代码来源:GamePad.cs

示例6: TouchesEnded

        internal void TouchesEnded( MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            UITouch []touchesArray = touches.ToArray<UITouch>();
            foreach(UITouch touch in touchesArray)
            {
                Vector2 location = new Vector2(touch.LocationInView(touch.View).X, touch.LocationInView(touch.View).Y);

                // Check where is the touch
                if (Visible)
                {
                    foreach(ButtonDefinition button in _buttonsDefinitions)
                    {
                        if  (CheckButtonHit(button, location))
                        {
                            _buttons &= ~(int)button.Type;
                        }
                    }
                    if ((_leftThumbDefinition != null) && (CheckThumbStickHit(_leftThumbDefinition,location)))
                    {
                        LeftThumbStickDefinition.Offset = Vector2.Zero;
                        _leftStick = Vector2.Zero;
                    }
                    if ((_rightThumbDefinition != null) && (CheckThumbStickHit(_rightThumbDefinition,location)))
                    {
                        _rightThumbDefinition.Offset = Vector2.Zero;
                        _rightStick = Vector2.Zero;
                    }
                }
            }
        }
开发者ID:QHebert,项目名称:monogame,代码行数:30,代码来源:GamePad.cs


注:本文中的MonoTouch.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。