本文整理汇总了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();
}
示例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;
//.........这里部分代码省略.........
示例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();
}
示例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;
}
}
}
}
}
示例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);
}
}
}
}
}
示例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;
}
}
}
}