本文整理汇总了C#中Microsoft.Xna.Framework.GameTime类的典型用法代码示例。如果您正苦于以下问题:C# GameTime类的具体用法?C# GameTime怎么用?C# GameTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GameTime类属于Microsoft.Xna.Framework命名空间,在下文中一共展示了GameTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(GameTime gameTime)
{
if (powerup == null)
{
if (remaining < 0)
{
remaining = rand.NextDouble() * 10 + 10;
lock (phyWorld)
powerup = (Powerup)Activator.CreateInstance(
types[rand.Next(0, types.Length)], phyWorld, gameplay, rand);
powerup.LoadContent(content);
}
else
remaining -= gameTime.ElapsedGameTime.TotalSeconds;
}
else
{
if (powerup.IsActive)
powerup.Update();
else
{
phyWorld.RemoveBody(powerup);
powerup = null;
}
}
}
示例2: Draw
public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
if (sprite != null && visible)
{
spriteBatch.Draw(sprite, position, null, Color.White, 0, Vector2.Zero, new Vector2(1, spriteScale), SpriteEffects.None, 0);
}
}
示例3: Update
protected override void Update(GameTime gameTime)
{
float time = (float)gameTime.ElapsedGameTime.TotalMilliseconds;
map.Update(time);
base.Update(gameTime);
}
示例4: Draw
protected override void Draw(GameTime gameTime)
{
base.Draw(gameTime);
this.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied);
this.spriteBatch.DrawString(this.font, "", new Vector2(1f, 1f), Color.White, 0f, Vector2.Zero, (float)1f, SpriteEffects.None, 1f);
this.spriteBatch.End();
}
示例5: Draw
/// <summary>
/// Draws the menu.
/// </summary>
public override void Draw(GameTime gameTime)
{
SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.Transform);
// Draw the menu title.
if (titleTexture == null)
spriteBatch.DrawString(ScreenManager.GameContent.gameFont, titleString,
titlePosition, Color.White * TransitionAlpha, 0, Vector2.Zero,
titleSize / ScreenManager.GameContent.gameFontSize,
SpriteEffects.None, 0);
else
spriteBatch.Draw(titleTexture, titlePosition, Color.White * TransitionAlpha);
// Draw each menu entry in turn.
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
bool isSelected = IsActive && (i == selectedEntry);
menuEntry.Draw(isSelected, gameTime);
}
spriteBatch.End();
}
示例6: Update
public override void Update(GameTime gameTime)
{
Position += Speed;
Angle += AngularSpeed;
Opacity -= OpacityChange;
CurrentLife += gameTime.ElapsedGameTime.Milliseconds;
}
示例7: Draw
/// <summary>
/// Allows the game component to update itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
public override void Draw(GameTime gameTime)
{
GestionSprites.Begin();
GestionSprites.DrawString(Font,TexteÀAfficher, Position, CouleurTexte,0,Origine,Échelle, SpriteEffects.None,1f);
GestionSprites.End();
base.Draw(gameTime);
}
示例8: Draw
public override void Draw(GameTime gameTime)
{
Matrix world = Matrix.CreateRotationY(this.rotation) * Matrix.CreateTranslation(this.position + (Vector3.Up * height));
Matrix[] transforms = new Matrix[this.model.Bones.Count];
this.model.CopyAbsoluteBoneTransformsTo(transforms);
GraphicsDevice.BlendState = BlendState.AlphaBlend;
GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
foreach (ModelMesh mesh in model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.World = transforms[mesh.ParentBone.Index] * world;
effect.View = CanyonGame.Camera.View;
effect.Projection = CanyonGame.Camera.Projection;
effect.Alpha = this.alpha;
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
}
mesh.Draw();
}
base.Draw(gameTime);
}
示例9: Draw
protected override void Draw(GameTime gameTime)
{
resolver.RunAllRunners();
if (runCodeForTests != null)
runCodeForTests();
resolver.RunAllPresenters();
}
示例10: Update
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
currentstate = Keyboard.GetState();
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// TODO: Add your update logic here
else
{
if (currentstate.IsKeyDown(Keys.A) && !oldstate.IsKeyDown(Keys.A))
{
sounds[0].Play();
//var sd = soundEffects[0].CreateInstance();
//sd.IsLooped = false;
//sd.Play();
//sd.Dispose();
}
if (currentstate.IsKeyDown(Keys.R) && !oldstate.IsKeyDown(Keys.R)) { rd.BMS파일분석(); }
if (currentstate.IsKeyDown(Keys.Y) && !oldstate.IsKeyDown(Keys.Y)) { rd.노트시간계산();sdmgr.시간들 = rd.시간들; }
if (currentstate.IsKeyDown(Keys.S) && !oldstate.IsKeyDown(Keys.S))
{
sdmgr.Play();
//var sd = soundEffects[1].CreateInstance();
//sd.Play();
}
oldstate = currentstate;
}
base.Update(gameTime);
}
示例11: Update
/// <summary>
/// Allows the game component to update itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
public override void Update(GameTime gameTime)
{
// TODO: Add your update code here
this.time += gameTime.ElapsedGameTime.Milliseconds;
if (this.time >= 1000)
{
this.time = 0;
this.s += 1;
//if (s >= 60)
//{
// s = 0;
// m += 1;
// if (m >= 60)
// h += 1;
//}
//if (h > 0)
// Console.WriteLine("時間計時:" + h + "小時" + m + "分" + s + "秒");
//else if (m > 0)
// Console.WriteLine("時間計時:" + m + "分" + s + "秒");
//else
Console.WriteLine("時間計時:" + s + "秒");
if (s > time_Max)
s = time_Max;
}
base.Update(gameTime);
}
示例12: Update
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
if (left.Clicked) this.SceneNavigator.MoveToScene(Scenes.SCENE_2);
if (right.Clicked) this.SceneNavigator.MoveToScene(Scenes.SCENE_2);
}
示例13: Draw
public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Vector2 position, SpriteEffects spriteEffects)
{
if (Animation == null)
{
throw new NotSupportedException("No animation is currently playing.");
}
time += (float)gameTime.ElapsedGameTime.TotalSeconds;
while (time > Animation.frameTime)
{
time -= Animation.frameTime;
if (Animation.isLooping)
{
frameIndex = (frameIndex + 1) % Animation.FrameCount;
}
else
{
frameIndex = Math.Min(frameIndex + 1, Animation.FrameCount - 1);
}
}
Rectangle source = new Rectangle(FrameIndex * Animation.FrameWidth, 0, Animation.FrameWidth, Animation.FrameHeight);
spriteBatch.Draw(animation.texture, position, source, Color.White, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0.0f);
}
示例14: Update
public override void Update(GameTime gameTime)
{
ControlManager.Update(gameTime, PlayerIndex.One);
base.Update(gameTime);
}
示例15: DrawFlagScore
public void DrawFlagScore(SpriteBatch spriteBatch, GameTime gameTime, float stoppingHeight)
{
scoreOrigin = ScoreFont.MeasureString(scoreText) / GameValues.ScoreSpriteScoreOriginOffset;
spriteBatch.DrawString(ScoreFont, scoreText, new Vector2(Position.X, Position.Y - GameValues.ScoreSpriteDrawFlagScoreYOffset), Color.White, 0, scoreOrigin, 0.4f, SpriteEffects.None, 0f);
if (Position.Y > stoppingHeight)
{
Position = new Vector2(Position.X, Position.Y - GameValues.ScoreSpriteDrawFlagScoreDropOffet);
}
else if (Position.Y <= stoppingHeight)
{
//Position.Y = stoppingHeight;
Position = new Vector2(Position.X, stoppingHeight);
if (scoreBuffer <= 0)
{
scoreBuffer = GameValues.ScoreSpriteScoreBuffer;
ScoringOn = !ScoringOn;
}
else
{
scoreBuffer--;
}
}
}