本文整理汇总了C#中Microsoft.Xna.Framework.GameTimer类的典型用法代码示例。如果您正苦于以下问题:C# GameTimer类的具体用法?C# GameTimer怎么用?C# GameTimer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GameTimer类属于Microsoft.Xna.Framework命名空间,在下文中一共展示了GameTimer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GamePage
public GamePage()
{
InitializeComponent();
// Get the application's ContentManager
content = (Application.Current as App).Content;
timer = new GameTimer { UpdateInterval = TimeSpan.FromTicks(333333) };
timer.Update += OnUpdate;
timer.Draw += OnDraw;
dispatcherTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(50) };
dispatcherTimer.Tick += (sender, e1) => Detect();
if (GameState.getInstance(false) != null)
{
GameState.getInstance().resetTurn();
}
//setup microphone and configure delegates that handle events
microphone.BufferDuration = TimeSpan.FromSeconds(1);
microphoneBuffer = new byte[microphone.GetSampleSizeInBytes(microphone.BufferDuration)];
BasicHttpBinding binding = new BasicHttpBinding() { MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue };
EndpointAddress address = new EndpointAddress(voiceRecognitionServerIP);
speechRecognitionClient = new ARVRClient(binding, address);
microphone.BufferReady += delegate
{
microphone.GetData(microphoneBuffer);
microphoneMemoryStream.Write(microphoneBuffer, 0, microphoneBuffer.Length);
};
speechRecognitionClient.RecognizeSpeechCompleted += new EventHandler<RecognizeSpeechCompletedEventArgs>(_client_RecognizeSpeechCompleted);
}
示例2: Animate
public void Animate(GameTimer timer, Player player)
{
if (player.IsAlive)
this.Position += direction * velocity * (float)timer.UpdateInterval.TotalSeconds;
if (this.assetName != "bomb")
{
if (currentFrame < animate.Length)
{
Source = sources[animate[currentFrame]];
currentFrame++;
}
else
currentFrame = 0;
}
else
{
if (this.Scale < 0.75f && smallest)
this.Scale += 0.6f * (float)timer.UpdateInterval.TotalSeconds;
else
{
smallest = false;
biggest = true;
}
if (this.Scale > 0.4f && biggest)
this.Scale -= 0.6f * (float)timer.UpdateInterval.TotalSeconds;
else
{
smallest = true;
biggest = false;
}
}
}
示例3: Update
public void Update(GameTimer timer)
{
this.Position += gravity * velocity * (float)timer.UpdateInterval.TotalSeconds;
if (this.Rotation < wRotation)
this.Rotation += 0.02f;
}
示例4: GamePage
public GamePage()
{
InitializeComponent();
// Obtenir le gestionnaire de contenu de l’application
contentManager = (Application.Current as App).Content;
// Créer un minuteur pour cette page
timer = new GameTimer();
timer.UpdateInterval = TimeSpan.FromTicks(333333);
timer.Update += OnUpdate;
timer.Draw += OnDraw;
this.map = new Map(this);
server = new Network();
this.plist = new List<Player>();
this.elist = new List<Egg>();
this.tlist = new List<string>();
this.lbc = new Queue<string>();
this.screen = new Microsoft.Xna.Framework.Rectangle(0, 0, 800, 480);
this.inventory_details = null;
this.inventory_timer = TimeSpan.Zero;
this.dot = new Vector2(640, 360);
this.end = false;
this.winner = "toto";
}
示例5: GameOverPage
public GameOverPage()
{
InitializeComponent();
App app = Application.Current as App;
Score.Text = "Score: " + app.Score.ToString("#,#");
app.Leaderboard.AddEntry(app.Score);
//for(int e = 0; e < app.Leaderboard.Entries.Count; e++)
//{
// Leaderboard.Text += app.Leaderboard.Entries[e].Rank + ". " + app.Leaderboard.Entries[e].Date + " " + app.Leaderboard.Entries[e].Score + "\n";
//}
graphicsDevice = SharedGraphicsDeviceManager.Current.GraphicsDevice;
// Get the content manager from the application
contentManager = (Application.Current as App).Content;
// Create a timer for this page
timer = new GameTimer();
timer.UpdateInterval = TimeSpan.FromTicks(333333);
timer.Update += OnUpdate;
timer.Draw += OnDraw;
LayoutUpdated += new EventHandler(GameOverPage_LayoutUpdated);
}
示例6: Update
public void Update(GameTimer timer, ContentManager theContentManager, PowerupHandler pu, Player player, bool soundMuted)
{
enemiesInLevel = (background.Period + 1) * 3;
elapsedTime += (float)timer.UpdateInterval.TotalSeconds;
if (elapsedTime > 45f / enemiesInLevel && readyEnemies.Count > 0) //45f = time to 4000px to pass (current background width = 2000px)
{
elapsedTime = 0;
readyEnemies[0].Position = new Vector2(player.Position.X + random.Next(760, 810), random.Next(110, 450));
visibleEnemies.Add(readyEnemies[0]);
readyEnemies.Remove(readyEnemies[0]);
}
foreach (Enemy e in visibleEnemies)
{
if (e.Position.X < player.Position.X - 100)
{
if (e.IsAlive && player.IsAlive)
player.score.AddPoints(-5);
e.IsAlive = true;
e.Hitpoints = maxHealth;
e.ExplosionCreated = false;
e.explosionHandler.explosions.Clear();
readyEnemies.Add(e);
visibleEnemies.Remove(e);
break;
}
e.Update(timer, pu, theContentManager, player, soundMuted);
}
}
示例7: GamePage
public GamePage()
{
InitializeComponent();
// Get the content manager from the application
contentManager = (Application.Current as App).Content;
// Create a timer for this page
timer = new GameTimer();
//timer.UpdateInterval = TimeSpan.FromTicks(333333);
// Using TimeSpan.Zero causes the update to happen
// at the actual framerate of the device. This makes
// animation much smoother. However, this will cause
// the speed of the app to vary from device to device
// where a fixed UpdateInterval will not.
timer.UpdateInterval = TimeSpan.Zero;
timer.Update += OnUpdate;
timer.Draw += OnDraw;
// Use the LayoutUpdate event to know when the page layout
// has completed so we can create the UIElementRenderer
LayoutUpdated += new EventHandler(GamePage_LayoutUpdated);
LayoutUpdated += new EventHandler(GamePage_LayoutUpdated);
}
示例8: GameBoard
Random rand; //random number generator
#endregion Fields
#region Constructors
//must pass lanewidth from Game1 object
public GameBoard( int displayWidth )
{
int laneWidth = displayWidth / ( laneCount );
//set up random numbers
this.rand = new Random();
this.Lanes = new int[7];
for( int i = 0; i < laneCount; i++ ) {
this.Lanes[i] = i * laneWidth;
}
this.currentNutList = new List<Nut>();
this.removeNutList = new List<Nut>();
//this.currentPineCones = new List<PineCone>();
//this.removePineCones = new List<PineCone>();
//sets up event, to affect frequency of nuts, adjust update interval...perhaps add randomness?
this.nutsFalling = new GameTimer();
nutsFalling.UpdateInterval = TimeSpan.FromSeconds(nutFrequency);
nutsFalling.Update += new EventHandler<GameTimerEventArgs>(generateNuts);
nutsFalling.Start();
//sets up level up timer
this.levelTimer = new GameTimer();
levelTimer.UpdateInterval = TimeSpan.FromSeconds(levelFrequency);
levelTimer.Update += new EventHandler<GameTimerEventArgs>(levelUp);
levelTimer.Start();
}
示例9: GamePage_Loaded
private void GamePage_Loaded(object sender, RoutedEventArgs e)
{
if (!pageLoaded)
{
manager = SharedGraphicsDeviceManager.Current;
manager.PreferredBackBufferWidth = (int)this.ActualWidth;
manager.PreferredBackBufferHeight = (int)this.ActualHeight;
manager.SwapChainPanel = this;
manager.ApplyChanges();
gameTimer = new GameTimer();
gameTimer.UpdateInterval = TimeSpan.FromTicks(166666);
gameTimer.Update += Update;
gameTimer.Draw += Draw;
this.SizeChanged += GamePage_SizeChanged;
// Le contenu est chargé une fois
LoadContent();
pageLoaded = true;
}
// L'initialisation doit se faire à chaque rechargement
Initialize();
}
示例10: Menu
public Menu()
{
InitializeComponent();
timer = new GameTimer();
timer.UpdateInterval = TimeSpan.FromTicks(333333);
timer.Update += OnUpdate;
this.image_PlayGame.Tap += new EventHandler<GestureEventArgs>(image_PlayGame_Tap);
}
示例11: Update
public void Update(GameTimer timer, bool move, bool soundMuted)
{
foreach (Explosion e in explosions)
{
e.Explode(soundMuted);
if (move)
e.Position += direction * velocity * (float)timer.UpdateInterval.TotalSeconds;
}
}
示例12: MapGamePageView
/// <summary>
/// Creates a new map game page view using the given content manager.
/// </summary>
/// <param name="contentManager"></param>
public MapGamePageView(ContentManager contentManager)
{
// Get the content manager from the application
_contentManager = contentManager;
// Create a timer for this page
_timer = new GameTimer();
_timer.UpdateInterval = TimeSpan.FromTicks(333333);
_timer.Update += OnUpdate;
_timer.Draw += OnDraw;
}
示例13: initializeGameTimer
public void initializeGameTimer()
{
Microsoft.Xna.Framework.GameTimer gameTimer = new Microsoft.Xna.Framework.GameTimer();
gameTimer.UpdateInterval = TimeSpan.FromMilliseconds(33);
gameTimer.Update += delegate { try { FrameworkDispatcher.Update(); } catch { } };
gameTimer.Start();
FrameworkDispatcher.Update();
}
示例14: PlayLevel
public PlayLevel()
{
InitializeComponent();
goalReached = false;
gameTime = new GameTimer();
gameTime.UpdateInterval = TimeSpan.FromSeconds(0.03);
gameTime.Update += new EventHandler<GameTimerEventArgs>(gameTime_Update);
levelName = "levelname";
GObjs = new List<GameObject>();
//deserializeJsonAsync();
// Load Level to the canvas
/*
EnemyTemp = new Enemy();
enemyNoGravity = false;
Enemies = new List<Enemy>();
Enemies.Add(new Enemy(10,10,10,10,10,1,1000,true,false));
Enemies.Add(new Enemy(10,100,10,10,10,1,1000,false,true));
foreach (Enemy e in Enemies)
{
Canvas.SetLeft(e.hitbox, e.Left);
Canvas.SetTop(e.hitbox, e.Top);
canvasWorld.Children.Add(e.hitbox);
}
*/
kbLeft = false;
kbRight = false;
topTemp = 0;
jump = 0;
doubleJumpAvaivable = true;
/*
//GObjs.Add(new GameObject(10,10,100,10));
GObjs.Add(new GameObject(100, 10, 100, 10));
GObjs.Add(new GameObject(150, 110, 100, 10));
GObjs.Add(new GameObject(200, 210, 100, 10));
GObjs.Add(new GameObject(250, 310, 100, 10));
foreach (GameObject go in GObjs)
{
Canvas.SetLeft(go.hitbox, go.Left);
Canvas.SetTop(go.hitbox, go.Top);
canvasWorld.Children.Add(go.hitbox);
}
*/
//MessageBox.Show("Start Game");
//gameTime.Start();
}
示例15: Animate
public void Animate(GameTimer timer, Player player)
{
foreach (Powerup pu in powerups)
{
pu.Animate(timer, player);
if (pu.X < -16)
{
powerups.Remove(pu);
break;
}
}
}