本文整理汇总了C#中TouchCollection类的典型用法代码示例。如果您正苦于以下问题:C# TouchCollection类的具体用法?C# TouchCollection怎么用?C# TouchCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TouchCollection类属于命名空间,在下文中一共展示了TouchCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:cragmire,项目名称:MVA,代码行数:27,代码来源:Button.cs
示例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));
}
开发者ID:Mikescher,项目名称:GridDominance,代码行数:29,代码来源:InputState.cs
示例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);
}
}
开发者ID:Vintharas,项目名称:War-of-the-Orbs,代码行数:26,代码来源:TouchIndicator.cs
示例4: Update
public void Update(TouchCollection NewCollection)
{
this.touchCollection = NewCollection;
Touch = touchCollection[0];
prevTouchState = curTouchState;
curTouchState = Touch.State;
}
开发者ID:TheKeveloper,项目名称:XNAHelper,代码行数:7,代码来源:TouchHelper.cs
示例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
}
开发者ID:JonathanMcCaffrey,项目名称:tank-gauntlet,代码行数:27,代码来源:Input.cs
示例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;
}
}
}
开发者ID:jallarzie,项目名称:spectrum,代码行数:28,代码来源:PhoneThumbsticController.cs
示例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)));
}
}
}
开发者ID:doanhtdpl,项目名称:boom-game,代码行数:26,代码来源:TouchController.cs
示例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));
}
开发者ID:hillwhite,项目名称:DeltaEngine,代码行数:7,代码来源:TouchCollectionTests.cs
示例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();
}
开发者ID:devedse,项目名称:TurtleTurner2000,代码行数:32,代码来源:Game1.cs
示例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();
}
开发者ID:cragmire,项目名称:MVA,代码行数:8,代码来源:MenuScreen.cs
示例11: InputManager
public InputManager()
{
this.OldState = new MouseState();
this.OldTouchState = new TouchCollection();
this.IsMouseDown = false;
this.IsMobile = LinesGame.IsMobile;
}
开发者ID:yegorf1,项目名称:Circles,代码行数:8,代码来源:InputManager.cs
示例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;
}
开发者ID:cgcoder,项目名称:StickyBird,代码行数:9,代码来源:PlayScreen.cs
示例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);
}
开发者ID:darrensapalo,项目名称:HumptyDumpty,代码行数:9,代码来源:GameOverScreen.cs
示例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);
}
开发者ID:darrensapalo,项目名称:HorrorGame,代码行数:10,代码来源:PauseScreen.cs
示例15: AnyTouch
/// <summary>
/// Determines if there are any touches on the screen.
/// </summary>
/// <param name="touchState">The current TouchCollection.</param>
/// <returns>True if there are any touches in the Pressed or Moved state, false otherwise</returns>
public static bool AnyTouch(TouchCollection touchState)
{
foreach (TouchLocation location in touchState)
{
if (location.State == TouchLocationState.Pressed || location.State == TouchLocationState.Moved)
{
return true;
}
}
return false;
}
开发者ID:salvadorc17,项目名称:Prince-Monogame,代码行数:16,代码来源:TouchCollectionExtensions.cs
示例16: Update
public void Update(TouchCollection toucheCollection, GameTime gameTime)
{
TouchLocation[] touchLocs = new TouchLocation[toucheCollection.Count];
int i = 0;
foreach (var touch in toucheCollection)
{
touchLocs[i++] = new TouchLocation(touch.Id, touch.State, orientation.Transform(touch.Position));
}
baseTC.Update(new TouchCollection(touchLocs), gameTime);
}
开发者ID:doanhtdpl,项目名称:plants-vs-zombies-gameonmobile-uit-term7,代码行数:11,代码来源:OrientedTouchController.cs
示例17: AddNewIndicators
/// <summary>
/// Add new touch indicators for new touch inputs
/// </summary>
/// <param name="content"></param>
/// <param name="currentTouchLocationState"></param>
private void AddNewIndicators(ContentManager content, TouchCollection currentTouchLocationState)
{
foreach (TouchLocation location in currentTouchLocationState)
{
bool isTouchIdAlreadyStored = touchPositions.Any(indicator => location.Id == indicator.TouchID);
if (!isTouchIdAlreadyStored)
{
TouchIndicator indicator = new TouchIndicator(location.Id, content);
touchPositions.Add(indicator);
}
}
}
开发者ID:Vintharas,项目名称:WP7projects,代码行数:17,代码来源:TouchIndicatorCollection.cs
示例18: WorksWhenConstructedEmpty
public void WorksWhenConstructedEmpty()
{
TouchCollection collection = new TouchCollection();
Assert.AreEqual(0, collection.Count);
foreach (var touch in collection)
Assert.Fail("Shouldn't have any touches in an empty collection");
Assert.AreEqual(-1, collection.IndexOf(new TouchLocation()));
TouchLocation touchLocation;
Assert.False(collection.FindById(1, out touchLocation));
}
开发者ID:Cardanis,项目名称:MonoGame,代码行数:13,代码来源:TouchCollectionTest.cs
示例19: 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());
}
}
开发者ID:umutseven92,项目名称:Romero.Windows,代码行数:29,代码来源:InputState.cs
示例20: update
public void update()
{
touches = TouchPanel.GetState();
if (touches.Count <= 2)
{
foreach (TouchLocation touch in touches)
{
if (ret.Contains((int)touch.Position.X, (int)touch.Position.Y) && touch.State == TouchLocationState.Pressed)
{
g.state = GameState.play;
g.player.stop();
}
else if (mainMenu.Contains((int)touch.Position.X, (int)touch.Position.Y) && touch.State == TouchLocationState.Pressed)
{
g.state = GameState.mainMenu;
}
else if (reset.Contains((int)touch.Position.X, (int)touch.Position.Y) && touch.State == TouchLocationState.Pressed)
{
g.state = GameState.play;
g.player.die();
}
}
}
GamePadState gamepadState = GamePad.GetState(PlayerIndex.One);
if (gamepadState.Buttons.Back == ButtonState.Pressed)
{
g.state = GameState.play;
g.player.stop();
}
}
开发者ID:jhedin,项目名称:Tilt,代码行数:30,代码来源:PauseMenu.cs
注:本文中的TouchCollection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论