本文整理汇总了C#中TouchCollection类的典型用法代码示例。如果您正苦于以下问题:C# TouchCollection类的具体用法?C# TouchCollection怎么用?C# TouchCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TouchCollection类属于命名空间,在下文中一共展示了TouchCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WasPressed
public bool WasPressed(ref TouchCollection touches)
{
foreach (var touch in touches)
{
if (touch.Id == _lastTouchId)
continue;
if (touch.State != TouchLocationState.Pressed)
continue;
if (_location.Contains(touch.Position))
{
_lastTouchId = touch.Id;
_pressed = true;
return true;
}
}
var mouseState = Mouse.GetState();
if (_location.Contains(mouseState.Position) && mouseState.LeftButton == ButtonState.Pressed)
{
_pressed = true;
return true;
}
_pressed = false;
return false;
}
示例2: InputState
private InputState(SAMViewportAdapter adapter, KeyboardState ks, MouseState ms, TouchCollection ts, GamePadState gs, InputState prev)
{
Mouse = ms;
Keyboard = ks;
TouchPanel = ts;
GamePad = gs;
if (Mouse.LeftButton == ButtonState.Pressed)
{
IsDown = true;
PointerPosition = adapter.PointToScreen(Mouse.Position);
}
else if (TouchPanel.Count > 0)
{
IsDown = true;
PointerPosition = adapter.PointToScreen(TouchPanel[0].Position.ToPoint());
}
else
{
IsDown = false;
PointerPosition = prev.PointerPosition;
}
IsJustDown = IsDown && !prev.IsDown;
IsJustUp = !IsDown && prev.IsDown;
lastKeyState = prev.currentKeyState;
currentKeyState = lastKeyState.ToDictionary(p => p.Key, p => ks.IsKeyDown(p.Key));
}
示例3: Update
public void Update(TouchCollection touchLocationState)
{
Vector2? currentPosition = TouchPosition(touchLocationState);
if (currentPosition == null)
{
if (touchPositions.Count > 0)
{
alphaValue -= 20;
if (alphaValue <= 0)
{
touchPositions.Clear();
alphaValue = 255;
}
}
}
else
{
if (alphaValue != 255)
{
touchPositions.Clear();
alphaValue = 255;
}
touchPositions.Add((Vector2)currentPosition);
}
}
示例4: Update
public void Update(TouchCollection NewCollection)
{
this.touchCollection = NewCollection;
Touch = touchCollection[0];
prevTouchState = curTouchState;
curTouchState = Touch.State;
}
示例5: Update
public static void Update()
{
m_Gesture = TouchPanel.IsGestureAvailable ? TouchPanel.ReadGesture() : new GestureSample();
if (CurrentTouchCollection.Count > 0)
{
OldTouchCollection = CurrentTouchCollection;
}
CurrentTouchCollection = TouchPanel.GetState();
if (CurrentTouchCollection.Count > 0)
{
while (TouchPanel.IsGestureAvailable)
{
TouchPanel.ReadGesture();
}
}
#if !Windows
m_LastKeyboardState = m_CurrentKeyboardState;
m_CurrentKeyboardState = Keyboard.GetState();
m_LastMouseState = m_CurrentMouseState;
m_CurrentMouseState = Mouse.GetState();
#endif
}
示例6: Update
public void Update(TouchCollection touchLocationState)
{
foreach (TouchLocation touchLocation in touchLocationState)
{
switch (touchLocation.State)
{
case TouchLocationState.Invalid:
break;
case TouchLocationState.Moved:
if (LastPressedLocation != null
&& getRectangleFromPoint(touchLocation.Position).Intersects(ListeningArea))
{
LastMovedLocation = touchLocation.Position;
}
break;
case TouchLocationState.Pressed:
if (getRectangleFromPoint(touchLocation.Position).Intersects(ListeningArea))
{
this.LastPressedLocation = touchLocation.Position;
}
break;
case TouchLocationState.Released:
LastPressedLocation = null;
LastMovedLocation = null;
break;
}
}
}
示例7: Update
public void Update(TouchCollection toucheCollection, GameTime gameTime)
{
List<ITouch> touchesCopy = new List<ITouch>(Touches);
this.Touches.Clear();
foreach (TouchLocation touchLocation in toucheCollection)
{
bool isBegin = true;
foreach (ITouch lastTouch in touchesCopy)
{
if (lastTouch.SystemTouch.Id == touchLocation.Id)
{
Touches.Add(new Touch(touchLocation, new TouchPositions(touchLocation.Position, lastTouch.Positions.Current, lastTouch.Positions.Begin)));
isBegin = false;
break;
}
}
if (isBegin)
{
Touches.Add(new Touch(touchLocation, new TouchPositions(touchLocation.Position, InvalidPosition, touchLocation.Position)));
}
}
}
示例8: FindFreeIndexWithoutAnyFreeIndices
public void FindFreeIndexWithoutAnyFreeIndices()
{
var touchCollection = new TouchCollection(null);
for (int index = 0; index < touchCollection.ids.Length; index++)
touchCollection.ids[index] = 1;
Assert.AreEqual(-1, touchCollection.FindIndexByIdOrGetFreeIndex(546));
}
示例9: Game1
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
String ip = "";
WebRequest req = WebRequest.Create("https://dl.dropbox.com/u/1814002/TurtleTurner2000/ip.txt");
WebResponse resp = req.GetResponse();
using (Stream streampje = resp.GetResponseStream())
{
using (TextReader reader = new StreamReader(streampje))
{
ip = reader.ReadLine();
}
}
deveClient = new DeveClient(ip, 1337);
deveClient.Start();
DeveOutgoingMessage outje = new DeveOutgoingMessage();
outje.WriteInt32((int)ServerReceiveMessageType.LoginMessageControlClient); //Join message
//outje.WriteInt32(1); //Android
deveClient.Send(outje);
graphics.IsFullScreen = true;
graphics.PreferredBackBufferWidth = 800;
graphics.PreferredBackBufferHeight = 480;
graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
this.currentTouchCollection = TouchPanel.GetState();
}
示例10: Update
public void Update(GameTime gameTime, TouchCollection touchState)
{
if (MediaPlayer.State != MediaState.Playing && MediaPlayer.GameHasControl)
MediaPlayer.Play(_song);
if (_startButton.WasPressed(ref touchState))
OnStart();
}
示例11: InputManager
public InputManager()
{
this.OldState = new MouseState();
this.OldTouchState = new TouchCollection();
this.IsMouseDown = false;
this.IsMobile = LinesGame.IsMobile;
}
示例12: HandleTouch
public override bool HandleTouch(TouchCollection tc)
{
base.HandleTouch(tc);
/*
* TouchLocation tl = tc[0];
bird.UpdatePosition(tl.Position.X, tl.Position.Y);
* */
return false;
}
示例13: Update
public override void Update(GameTime gameTime, TouchCollection tc)
{
if (tc.Count > 0)
{
game.changeScreen(ScreenType.MainMenuScreen);
game.getHumptyDumpty().Status = HumptyDumpty.ALIVE;
}
base.Update(gameTime, tc);
}
示例14: Update
public override void Update(GameTime gameTime, TouchCollection collection, Vector3 acceleration)
{
countdown += gameTime.ElapsedGameTime.Milliseconds;
if (countdown > 2000)
{
countdown = 0;
gameReference.changeScreen(ScreenType.GameScreen);
}
base.Update(gameTime, collection, acceleration);
}
示例15: Update
/// <summary>
/// Reads the latest state of the keyboard and gamepad.
/// </summary>
public void Update()
{
for (var i = 0; i < MaxInputs; i++)
{
LastKeyboardStates[i] = CurrentKeyboardStates[i];
LastGamePadStates[i] = CurrentGamePadStates[i];
CurrentKeyboardStates[i] = Keyboard.GetState((PlayerIndex)i);
CurrentGamePadStates[i] = GamePad.GetState((PlayerIndex)i);
// Keep track of whether a gamepad has ever been
// connected, so we can detect if it is unplugged.
if (CurrentGamePadStates[i].IsConnected)
{
GamePadWasConnected[i] = true;
}
}
TouchState = TouchPanel.GetState();
Gestures.Clear();
while (TouchPanel.IsGestureAvailable)
{
Gestures.Add(TouchPanel.ReadGesture());
}
}