Jypeli  5
The simple game programming library
Accelerometer.cs
Siirry tämän tiedoston dokumentaatioon.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Diagnostics;
6 using Microsoft.Xna.Framework;
7 
8 #if WINDOWS_PHONE
9 
10 using Microsoft.Devices.Sensors;
11 using XNAaccelerometer = Microsoft.Devices.Sensors.Accelerometer;
12 
13 #endif
14 
15 using Jypeli.Controls;
16 
17 /*
18  * Authors: Jaakko Kosonen
19  */
20 
21 namespace Jypeli.WP7
22 {
27  {
31  Any,
32 
36  Left,
37 
41  Right,
42 
46  Up,
47 
51  Down,
52 
56  Shake,
57 
61  Tap
62  }
63 
67  public enum AccelerometerSensitivity : int
68  {
72  Realtime = 1,
73 
77  High = 20,
78 
82  Medium = 50,
83 
87  Low = 70,
88  }
89 
95  {
99  ZeroAngle,
100 
105 
109  RightAngle,
110  }
111 
115  public class Accelerometer : Controller<Vector3>
116  {
117  private double deltaX;
118  private double deltaY;
119  private double deltaZ;
120 
124  private Vector3 memoryState = Vector3.Zero;
125 
129  public Vector Reading
130  {
131  get
132  {
133  switch (Calibration)
134  {
135  case AccelerometerCalibration.ZeroAngle:
136  return new Vector(newState.X, newState.Y);
137  case AccelerometerCalibration.HalfRightAngle:
138  return new Vector(newState.X, newState.Y - newState.Z);
139  case AccelerometerCalibration.RightAngle:
140  return new Vector(newState.X, -newState.Z);
141  default:
142  return new Vector(newState.X, newState.Y);
143  }
144  }
145  }
146 
150  public Vector3 State
151  {
152  get { return newState; }
153  }
154 
158  public AccelerometerCalibration Calibration { get; set; }
159 
163  public WP7.DisplayOrientation DisplayOrientation { get; set; }
164 
165  private double _defaultSensitivity;
169  public double DefaultSensitivity { get { return _defaultSensitivity; } }
170 
171  private double _defaultAnalogSensitivity;
175  public double DefaultAnalogSensitivity { get { return _defaultAnalogSensitivity; } }
176 
180  public Boolean GesturesEnabled { get; set; }
181 
185  public int TimeBetweenTaps { get; set; }
186 
190  public int TimeBetweenShakes { get; set; }
191 
192 #if WINDOWS_PHONE
193 
194  private bool accMeterStarted;
195  private XNAaccelerometer accelerometer;
196 
200  public Accelerometer()
201  {
202  accelerometer = new XNAaccelerometer();
203  accelerometer.ReadingChanged += new EventHandler<AccelerometerReadingEventArgs>(accelerometer_ReadingChanged);
204  Calibration = AccelerometerCalibration.ZeroAngle;
205  DisplayOrientation = WP7.DisplayOrientation.Landscape;
206  _defaultSensitivity = 0.2;
207  _defaultAnalogSensitivity = 0.01;
208  GesturesEnabled = true;
209  TimeBetweenTaps = 300;
210  TimeBetweenShakes = 500;
211  accMeterStarted = false;
212  }
213 
214 #endif
215  public void Start()
219  {
220 #if WINDOWS_PHONE
221  if (!accMeterStarted)
222  {
223  accelerometer.Start();
224  accMeterStarted = true;
225  }
226 #endif
227  }
228 
232  public void Stop()
233  {
234 #if WINDOWS_PHONE
235  accelerometer.Stop();
236  accMeterStarted = false;
237 #endif
238  }
239 
244  public void PauseForDuration(double seconds)
245  {
246  Stop();
247  Timer.SingleShot(seconds, Start);
248  }
249 
254  public void SetDefaultSensitivity(double sensitivity)
255  {
256  SetDefaultSensitivity(sensitivity, ListeningType.Accelerometer);
257  }
258 
264  {
265  SetDefaultSensitivity((double)sensitivity / 100, ListeningType.Accelerometer);
266  }
267 
272  public void SetDefaultAnalogSensitivity(double sensitivity)
273  {
274  SetDefaultSensitivity(sensitivity, ListeningType.ControllerAnalogMovement);
275  }
276 
282  {
283  SetDefaultSensitivity((double)sensitivity / 100, ListeningType.ControllerAnalogMovement);
284  }
285 
286  private void SetDefaultSensitivity(double sens, ListeningType type)
287  {
288  switch (type)
289  {
290  case ListeningType.ControllerAnalogMovement:
291  _defaultAnalogSensitivity = sens;
292  break;
293  case ListeningType.Accelerometer:
294  _defaultSensitivity = sens;
295  break;
296  default:
297  break;
298  }
299  }
300 
301  internal override bool IsBufferEmpty()
302  {
303  return true;
304  }
305 
309  public void EnableAnalog()
310  {
311  base.Enable( listener => ( listener.Type == ListeningType.ControllerAnalogMovement ) );
312  }
313 
317  public void DisableAnalog()
318  {
319  base.Disable( listener => ( listener.Type == ListeningType.ControllerAnalogMovement ) );
320  }
321 
326  public void Enable( AccelerometerDirection direction )
327  {
328  base.Enable( listener => ( listener.AccelerometerDirection == direction ) );
329  }
330 
335  public void Disable( AccelerometerDirection direction )
336  {
337  base.Disable( listener => ( listener.AccelerometerDirection == direction ) );
338  }
339 
340  internal override string GetControlText(Listener listener)
341  {
342  if (listener.Type != ListeningType.Accelerometer && listener.Type != ListeningType.ControllerAnalogMovement)
343  Debug.Assert(false, "Bad listener type for accelerometer");
344  return "Accelerometer";
345  }
346 
347 #if WINDOWS_PHONE
348 
349  private void accelerometer_ReadingChanged(object sender, AccelerometerReadingEventArgs e)
350  {
351  switch (DisplayOrientation)
352  {
353  case WP7.DisplayOrientation.Landscape:
354  memoryState.X = -(float)e.Y;
355  memoryState.Y = (float)e.X;
356  memoryState.Z = (float)e.Z;
357  break;
358  case WP7.DisplayOrientation.LandscapeLeft:
359  memoryState.X = -(float)e.Y;
360  memoryState.Y = (float)e.X;
361  memoryState.Z = (float)e.Z;
362  break;
363  case WP7.DisplayOrientation.LandscapeRight:
364  memoryState.X = -(float)e.Y;
365  memoryState.Y = -(float)e.X;
366  memoryState.Z = (float)e.Z;
367  break;
368  case WP7.DisplayOrientation.Portrait:
369  memoryState.X = (float)e.X;
370  memoryState.Y = (float)e.Y;
371  memoryState.Z = (float)e.Z;
372  break;
373  default:
374  memoryState.X = (float)e.X;
375  memoryState.Y = (float)e.Y;
376  memoryState.Z = (float)e.Z;
377  break;
378  }
379  }
380 
381  internal override void Update()
382  {
383  if ( !accMeterStarted )
384  return;
385 
386  base.Update();
387  }
388 
389 #endif
390 
391  internal override Vector3 GetCurrentState()
392  {
393  return memoryState;
394  }
395 
396  protected override void UpdateState()
397  {
398  deltaY = Math.Abs( newState.Y - oldState.Y );
399  deltaX = Math.Abs( newState.X - oldState.X );
400  deltaZ = Math.Abs( newState.Z - oldState.Z );
401  }
402 
403 #if WINDOWS_PHONE
404 
405  protected override bool IsTriggered( Listener listener )
406  {
407  if ( listener.Type == ListeningType.Accelerometer )
408  return IsAccTriggered( listener, Reading );
409 
410  return base.IsTriggered( listener );
411  }
412 
413  protected override bool IsAnalogTriggered( Listener listener, out AnalogState state )
414  {
415  if ( listener.Type == ListeningType.ControllerAnalogMovement )
416  return IsAccTriggeredAnalog( listener, out state, Reading );
417 
418  return base.IsAnalogTriggered( listener, out state );
419  }
420 
421  private bool IsAccTriggered(Listener l, Vector reading)
422  {
423  double sensitivity = l.AccelerometerSensitivity;
424  switch (l.AccelerometerDirection)
425  {
426  case AccelerometerDirection.Any:
427  return Math.Abs(reading.X) > sensitivity || Math.Abs(reading.Y) > sensitivity;
428  case AccelerometerDirection.Left:
429  return reading.X < -sensitivity;
430  case AccelerometerDirection.Right:
431  return reading.X > sensitivity;
432  case AccelerometerDirection.Up:
433  return reading.Y > sensitivity;
434  case AccelerometerDirection.Down:
435  return reading.Y < -sensitivity;
436  case AccelerometerDirection.Shake:
437  return GestureTrickered(l, 3);
438  case AccelerometerDirection.Tap:
439  return GestureTrickered(l, 1);
440  default:
441  return false;
442  }
443  }
444 
445  private bool IsAccTriggeredAnalog(Listener l, out AnalogState state, Vector reading)
446  {
447  if (reading.Magnitude > l.AccelerometerSensitivity)
448  {
449  state = new AnalogState(0.0, 0.0, new Vector(reading.X, reading.Y));
450  return true;
451  }
452  state = new AnalogState();
453  return false;
454  }
455 
456  #region Gestures
457 
458  private bool GestureTrickered(Listener listener, int minGestureCount)
459  {
460  if (!GesturesEnabled) return false;
461  if (IsSamplingTimeOver(listener) && listener.AccelerometerGestureCount >= minGestureCount)
462  {
463  SetLastGesture(listener);
464  return true;
465  }
466  else if (TimeToGetSample(listener))
467  {
468  bool gestureDetected;
469  switch (listener.AccelerometerDirection)
470  {
471  case AccelerometerDirection.Shake:
472  gestureDetected = Shaked(listener.AccelerometerSensitivity);
473  break;
474  case AccelerometerDirection.Tap:
475  gestureDetected = Tapped(listener.AccelerometerSensitivity);
476  break;
477  default:
478  gestureDetected = false;
479  break;
480  }
481  HandleSampling(gestureDetected, listener);
482  }
483  return false;
484  }
485 
486  private bool Shaked(double trigger)
487  {
488  double threshold = (trigger + 1) * 2;
489  return deltaX + deltaY > threshold ||
490  deltaX + deltaZ > threshold ||
491  deltaY + deltaZ > threshold;
492  }
493 
494  private bool Tapped(double trigger)
495  {
496  double threshold = trigger + 0.2;
497  return !Shaked(0) &&
498  ( deltaX > threshold ||
499  deltaY > threshold ||
500  deltaZ > threshold );
501  }
502 
503  private void HandleSampling(bool gestureDetected, Listener listener)
504  {
505  if (listener.AccelerometerGestureCount == 0 && gestureDetected)
506  {
507  listener.AccelerometerGestureSamplingStartTime = Game.Time.SinceStartOfGame.TotalMilliseconds;
508  }
509  listener.AccelerometerGestureCount += gestureDetected ? 1 : 0;
510  }
511 
512  private bool TimeToGetSample(Listener listener)
513  {
514  switch (listener.AccelerometerDirection)
515  {
516  case AccelerometerDirection.Shake:
517  return Game.Time.SinceStartOfGame.TotalMilliseconds > listener.AccelerometerLastGesture + TimeBetweenShakes;
518  case AccelerometerDirection.Tap:
519  return Game.Time.SinceStartOfGame.TotalMilliseconds > listener.AccelerometerLastGesture + TimeBetweenTaps;
520  default:
521  return false;
522  }
523  }
524 
525  private bool IsSamplingTimeOver(Listener listener)
526  {
527  switch (listener.AccelerometerDirection)
528  {
529  case AccelerometerDirection.Shake:
530  return Game.Time.SinceStartOfGame.TotalMilliseconds > listener.AccelerometerGestureSamplingStartTime + TimeBetweenShakes / 5;
531  case AccelerometerDirection.Tap:
532  return Game.Time.SinceStartOfGame.TotalMilliseconds > listener.AccelerometerGestureSamplingStartTime + TimeBetweenTaps / 10;
533  default:
534  return false;
535  }
536  }
537 
538  private void SetLastGesture(Listener listener)
539  {
540  listener.AccelerometerGestureCount = 0;
541  listener.AccelerometerLastGesture = Game.Time.SinceStartOfGame.TotalMilliseconds;
542  }
543 
544  #endregion
545 
546 #endif
547 
548  #region Listen with no parameters
549 
550  public void Listen(AccelerometerDirection direction, Handler handler, string helpText)
551  {
552  this.Listen(direction, DefaultSensitivity, handler, helpText);
553  }
554 
555  public void ListenAnalog(AnalogHandler handler, string helpText)
556  {
557  this.ListenAnalog(DefaultAnalogSensitivity, handler, helpText);
558  }
559 
560  public void Listen(AccelerometerDirection direction, AccelerometerSensitivity sensitivity, Handler handler, string helpText)
561  {
562  this.Listen(direction, (int)sensitivity / 100, handler, helpText);
563  }
564 
565  public void ListenAnalog(AccelerometerSensitivity sensitivity, AnalogHandler handler, string helpText)
566  {
567  this.ListenAnalog((int)sensitivity / 100, handler, helpText);
568  }
569 
570  public void Listen(AccelerometerDirection direction, double trigger, Handler handler, string helpText)
571  {
572 #if WINDOWS_PHONE
573  Listener l = new SimpleListener(this, ListeningType.Accelerometer, helpText, handler);
574  l.AccelerometerDirection = direction;
575  l.AccelerometerSensitivity = trigger;
576  Add(l);
577  Start();
578 #endif
579  }
580 
581  public void ListenAnalog(double trigger, AnalogHandler handler, string helpText)
582  {
583 #if WINDOWS_PHONE
584  Listener l = new AnalogListener( this, ListeningType.ControllerAnalogMovement, helpText, handler );
585  l.AccelerometerSensitivity = trigger;
586  Add(l);
587  Start();
588 #endif
589  }
590 
591  #endregion
592 
593  #region Listen with 1 parameter
594 
595  public void Listen<T1>(AccelerometerDirection direction, Handler<T1> handler, string helpText, T1 p1)
596  {
597  this.Listen(direction, DefaultSensitivity, handler, helpText, p1);
598  }
599 
600  public void ListenAnalog<T1>(AnalogHandler<T1> handler, string helpText, T1 p1)
601  {
602  this.ListenAnalog(DefaultAnalogSensitivity, handler, helpText, p1);
603  }
604 
605  public void Listen<T1>(AccelerometerDirection direction, AccelerometerSensitivity sensitivity, Handler<T1> handler, string helpText, T1 p1)
606  {
607  this.Listen(direction, (double)sensitivity / 100, handler, helpText, p1);
608  }
609 
610  public void ListenAnalog<T1>(AccelerometerSensitivity sensitivity, AnalogHandler<T1> handler, string helpText, T1 p1)
611  {
612  this.ListenAnalog((double)sensitivity / 100, handler, helpText, p1);
613  }
614 
615  public void Listen<T1>(AccelerometerDirection direction, double trigger, Handler<T1> handler, string helpText, T1 p1)
616  {
617 #if WINDOWS_PHONE
618  Listener l = new SimpleListener<T1>( this, ListeningType.Accelerometer, helpText, handler, p1 );
619  l.AccelerometerDirection = direction;
620  l.AccelerometerSensitivity = trigger;
621  Add(l);
622  Start();
623 #endif
624  }
625 
626  public void ListenAnalog<T1>(double trigger, AnalogHandler<T1> handler, string helpText, T1 p1)
627  {
628 #if WINDOWS_PHONE
629  Listener l = new AnalogListener<T1>( this, ListeningType.ControllerAnalogMovement, helpText, handler, p1 );
630  l.AccelerometerSensitivity = trigger;
631  Add(l);
632  Start();
633 #endif
634  }
635 
636  #endregion
637 
638  #region Listen with 2 parameters
639 
640  public void Listen<T1, T2>(AccelerometerDirection direction, Handler<T1, T2> handler, string helpText, T1 p1, T2 p2)
641  {
642  this.Listen(direction, DefaultSensitivity, handler, helpText, p1, p2);
643  }
644 
645  public void ListenAnalog<T1, T2>(AnalogHandler<T1, T2> handler, string helpText, T1 p1, T2 p2)
646  {
647  this.ListenAnalog(DefaultAnalogSensitivity, handler, helpText, p1, p2);
648  }
649 
650  public void Listen<T1, T2>(AccelerometerDirection direction, AccelerometerSensitivity sensitivity, Handler<T1, T2> handler, string helpText, T1 p1, T2 p2)
651  {
652  this.Listen(direction, (double)sensitivity / 100, handler, helpText, p1, p2);
653  }
654 
655  public void ListenAnalog<T1, T2>(AccelerometerSensitivity sensitivity, AnalogHandler<T1, T2> handler, string helpText, T1 p1, T2 p2)
656  {
657  this.ListenAnalog((double)sensitivity / 100, handler, helpText, p1, p2);
658  }
659 
660  public void Listen<T1, T2>(AccelerometerDirection direction, double trigger, Handler<T1, T2> handler, string helpText, T1 p1, T2 p2)
661  {
662 #if WINDOWS_PHONE
663  Listener l = new SimpleListener<T1, T2>( this, ListeningType.Accelerometer, helpText, handler, p1, p2 );
664  l.AccelerometerDirection = direction;
665  l.AccelerometerSensitivity = trigger;
666  Add(l);
667  Start();
668 #endif
669  }
670 
671  public void ListenAnalog<T1, T2>(double trigger, AnalogHandler<T1, T2> handler, string helpText, T1 p1, T2 p2)
672  {
673 #if WINDOWS_PHONE
674  Listener l = new AnalogListener<T1, T2>( this, ListeningType.ControllerAnalogMovement, helpText, handler, p1, p2 );
675  l.AccelerometerSensitivity = trigger;
676  Add(l);
677  Start();
678 #endif
679  }
680 
681  #endregion
682 
683  #region Listen with 3 parameters
684 
685  public void Listen<T1, T2, T3>(AccelerometerDirection direction, Handler<T1, T2, T3> handler, string helpText, T1 p1, T2 p2, T3 p3)
686  {
687  this.Listen(direction, DefaultSensitivity, handler, helpText, p1, p2, p3);
688  }
689 
690  public void ListenAnalog<T1, T2, T3>(AnalogHandler<T1, T2, T3> handler, string helpText, T1 p1, T2 p2, T3 p3)
691  {
692  this.ListenAnalog(DefaultAnalogSensitivity, handler, helpText, p1, p2, p3);
693  }
694 
695  public void Listen<T1, T2, T3>(AccelerometerDirection direction, AccelerometerSensitivity sensitivity, Handler<T1, T2, T3> handler, string helpText, T1 p1, T2 p2, T3 p3)
696  {
697  this.Listen(direction, (double)sensitivity / 100, handler, helpText, p1, p2, p3);
698  }
699 
700  public void ListenAnalog<T1, T2, T3>(AccelerometerSensitivity sensitivity, AnalogHandler<T1, T2, T3> handler, string helpText, T1 p1, T2 p2, T3 p3)
701  {
702  this.ListenAnalog((double)sensitivity / 100, handler, helpText, p1, p2, p3);
703  }
704 
705  public void Listen<T1, T2, T3>(AccelerometerDirection direction, double trigger, Handler<T1, T2, T3> handler, string helpText, T1 p1, T2 p2, T3 p3)
706  {
707 #if WINDOWS_PHONE
708  Listener l = new SimpleListener<T1, T2, T3>( this, ListeningType.Accelerometer, helpText, handler, p1, p2, p3 );
709  l.AccelerometerDirection = direction;
710  l.AccelerometerSensitivity = trigger;
711  Add(l);
712  Start();
713 #endif
714  }
715 
716  public void ListenAnalog<T1, T2, T3>(double trigger, AnalogHandler<T1, T2, T3> handler, string helpText, T1 p1, T2 p2, T3 p3)
717  {
718 #if WINDOWS_PHONE
719  Listener l = new AnalogListener<T1, T2, T3>( this, ListeningType.ControllerAnalogMovement, helpText, handler, p1, p2, p3 );
720  l.AccelerometerSensitivity = trigger;
721  Add(l);
722  Start();
723 #endif
724  }
725 
726  #endregion
727 
728  #region Listen with 4 parameters
729 
730  public void Listen<T1, T2, T3, T4>(AccelerometerDirection direction, Handler<T1, T2, T3, T4> handler, string helpText, T1 p1, T2 p2, T3 p3, T4 p4)
731  {
732  this.Listen(direction, DefaultSensitivity, handler, helpText, p1, p2, p3, p4);
733  }
734 
735  public void ListenAnalog<T1, T2, T3, T4>(AnalogHandler<T1, T2, T3, T4> handler, string helpText, T1 p1, T2 p2, T3 p3, T4 p4)
736  {
737  this.ListenAnalog(DefaultAnalogSensitivity, handler, helpText, p1, p2, p3, p4);
738  }
739 
740  public void Listen<T1, T2, T3, T4>(AccelerometerDirection direction, AccelerometerSensitivity sensitivity, Handler<T1, T2, T3, T4> handler, string helpText, T1 p1, T2 p2, T3 p3, T4 p4)
741  {
742  this.Listen(direction, (double)sensitivity / 100, handler, helpText, p1, p2, p3, p4);
743  }
744 
745  public void ListenAnalog<T1, T2, T3, T4>(AccelerometerSensitivity sensitivity, AnalogHandler<T1, T2, T3, T4> handler, string helpText, T1 p1, T2 p2, T3 p3, T4 p4)
746  {
747  this.ListenAnalog((double)sensitivity / 100, handler, helpText, p1, p2, p3, p4);
748  }
749 
750  public void Listen<T1, T2, T3, T4>(AccelerometerDirection direction, double trigger, Handler<T1, T2, T3, T4> handler, string helpText, T1 p1, T2 p2, T3 p3, T4 p4)
751  {
752 #if WINDOWS_PHONE
753  Listener l = new SimpleListener<T1, T2, T3, T4>( this, ListeningType.Accelerometer, helpText, handler, p1, p2, p3, p4 );
754  l.AccelerometerDirection = direction;
755  l.AccelerometerSensitivity = trigger;
756  Add(l);
757  Start();
758 #endif
759  }
760 
761  public void ListenAnalog<T1, T2, T3, T4>(double trigger, AnalogHandler<T1, T2, T3, T4> handler, string helpText, T1 p1, T2 p2, T3 p3, T4 p4)
762  {
763 #if WINDOWS_PHONE
764  Listener l = new AnalogListener<T1, T2, T3, T4>( this, ListeningType.ControllerAnalogMovement, helpText, handler, p1, p2, p3, p4 );
765  l.AccelerometerSensitivity = trigger;
766  Add(l);
767  Start();
768 #endif
769  }
770 
771  #endregion
772 
773  }
774 }
AccelerometerDirection
Suunta/ele joka tunnistetaan.
double Magnitude
Vektorin pituus.
Definition: Vector.cs:281
Nappi on ylhäällä.
Kallistus/ele tunnistetaan nopeasti.
void SetDefaultAnalogSensitivity(AccelerometerSensitivity sensitivity)
Asettaa vakioherkkyydeksi (analoginen) annetun arvon.
Puhelin on vaakatasossa näyttö ylöspäin.
Nappi on alhaalla.
override void UpdateState()
DisplayOrientation
Puhelimen näytön asemointi.
Definition: Phone.cs:17
void SetDefaultSensitivity(AccelerometerSensitivity sensitivity)
Asettaa vakioherkkyydeksi annetun arvon.
TimeSpan SinceStartOfGame
Aika joka on kulunut pelin alusta.
Definition: Time.cs:32
void Listen(AccelerometerDirection direction, AccelerometerSensitivity sensitivity, Handler handler, string helpText)
void Listen(AccelerometerDirection direction, double trigger, Handler handler, string helpText)
delegate void AnalogHandler< T1, T2 >(AnalogState analogState, T1 p1, T2 p2)
Ohjaintapahtumankäsittelijä kahdella parametrilla.
Puhelimen kiihtyvyysanturi.
void ListenAnalog(AccelerometerSensitivity sensitivity, AnalogHandler handler, string helpText)
delegate void Handler< T1, T2, T3 >(T1 p1, T2 p2, T3 p3)
Ohjaintapahtumankäsittelijä kolmella parametrilla.
double Y
Definition: Vector.cs:275
Puhelimen "nopea liike"-ele, esim. näpäytys tai tärähdys.
Peliluokka reaaliaikaisille peleille.
Definition: DebugScreen.cs:10
void Disable(AccelerometerDirection direction)
Poistaa kiihtyvyyskontrollin k käytöstä.
static void SingleShot(double seconds, Action onTimeout)
Kutsuu aliohjelmaa onTimeout annetun ajan kuluttua. Ajastin luodaan automaattisesti.
Definition: Timer.cs:186
delegate void AnalogHandler(AnalogState analogState)
Ohjaintapahtumankäsittelijä ilman parametreja.
delegate void Handler< T1 >(T1 p1)
Ohjaintapahtumankäsittelijä yhdellä parametrilla.
Parametrit analogisen ohjauksen (hiiren tai ohjaustikun) tapahtumalle.
Definition: AnalogState.cs:35
void EnableAnalog()
Ottaa käytöstä poistetun kiihtyvyyskontrollin analogikontrollit k takaisin käyttöön.
Kallistus/ele tunnistetaan melko myöhään.
double X
Definition: Vector.cs:274
void PauseForDuration(double seconds)
Pysäyttää kiihtyvyysanturin annetuksi ajaksi.
void DisableAnalog()
Poistaa kiihtyvyysanturin analogikontrollit k käytöstä.
AccelerometerSensitivity
Herkkyys jolla kallistus/ele halutaan tunnistaa.
delegate void Handler()
Ohjaintapahtumankäsittelijä ilman parametreja.
Ajastin, joka voidaan asettaa laukaisemaan tapahtumia tietyin väliajoin.
Definition: Timer.cs:39
void SetDefaultSensitivity(double sensitivity)
Asettaa vakioherkkyydeksi annetun arvon.
static Time Time
Peliaika. Sisältää tiedon siitä, kuinka kauan peliä on pelattu (Time.SinceStartOfGame) ja kuinka kaua...
Definition: Game.cs:309
delegate void Handler< T1, T2 >(T1 p1, T2 p2)
Ohjaintapahtumankäsittelijä kahdella parametrilla.
delegate void AnalogHandler< T1, T2, T3 >(AnalogState analogState, T1 p1, T2 p2, T3 p3)
Ohjaintapahtumankäsittelijä kolmella parametrilla.
void Enable(AccelerometerDirection direction)
Ottaa käytöstä poistetun kiihtyvyyskontrollin k takaisin käyttöön.
void ListenAnalog(double trigger, AnalogHandler handler, string helpText)
Kallistus/ele tunnistetaan melko nopeasti.
Kallistus/ele tunnistetaan myöhään.
void Listen(AccelerometerDirection direction, Handler handler, string helpText)
kallistetaan mihin tahansa suuntaan.
delegate void Handler< T1, T2, T3, T4 >(T1 p1, T2 p2, T3 p3, T4 p4)
Ohjaintapahtumankäsittelijä neljällä parametrilla.
2D-vektori.
Definition: Vector.cs:56
delegate void AnalogHandler< T1 >(AnalogState analogState, T1 p1)
Ohjaintapahtumankäsittelijä yhdellä parametrilla.
delegate void AnalogHandler< T1, T2, T3, T4 >(AnalogState analogState, T1 p1, T2 p2, T3 p3, T4 p4)
Ohjaintapahtumankäsittelijä neljällä parametrilla.
AccelerometerCalibration
Kalibrointi puhelimen kallistuksen nollakohdalle. (Asento missä puhelinta ei ole kallistettu yhtään) ...
void ListenAnalog(AnalogHandler handler, string helpText)
void Stop()
Pysäyttää kiihtyvyysanturin.
void SetDefaultAnalogSensitivity(double sensitivity)
Asettaa vakioherkkyydeksi (analoginen) annetun arvon.
Yleinen peliohjainluokka.
Definition: Controller.cs:40