本文整理汇总了C#中GameTime类的典型用法代码示例。如果您正苦于以下问题:C# GameTime类的具体用法?C# GameTime怎么用?C# GameTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GameTime类属于命名空间,在下文中一共展示了GameTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Game
public Game(UserControl userControl, Canvas drawingCanvas, Canvas debugCanvas, TextBlock txtDebug)
{
//Initialize
IsActive = true;
IsFixedTimeStep = true;
TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 16);
Components = new List<DrawableGameComponent>();
World = new World(new Vector2(0, 0));
_gameTime = new GameTime();
_gameTime.GameStartTime = DateTime.Now;
_gameTime.FrameStartTime = DateTime.Now;
_gameTime.ElapsedGameTime = TimeSpan.Zero;
_gameTime.TotalGameTime = TimeSpan.Zero;
//Setup Canvas
DrawingCanvas = drawingCanvas;
DebugCanvas = debugCanvas;
TxtDebug = txtDebug;
UserControl = userControl;
//Setup GameLoop
_gameLoop = new Storyboard();
_gameLoop.Completed += GameLoop;
_gameLoop.Duration = TargetElapsedTime;
DrawingCanvas.Resources.Add("gameloop", _gameLoop);
}
示例2: Draw
public override void Draw(GameTime gameTime)
{
if (isVisible)
{
//create effect object
//create orthographic projection matrix (basically discards Z value of a vertex)
Matrix projection = Matrix.CreateOrthographicOffCenter(0.0f, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height, 0.0f, 0.1f, 10.0f);
//set effect properties
be.Projection = projection;
be.View = Matrix.Identity;
be.World = Matrix.Identity;
//be.VertexColorEnabled = true;
//change viewport to fit desired grid
GraphicsDevice.Viewport = new Viewport(gridrect);
//set vertex/pixel shaders from the effect
be.Techniques[0].Passes[0].Apply();
//draw the lines
GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vlines, 0, xC + 1);
GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, hlines, 0, yC + 1);
}
base.Draw(gameTime);
}
示例3: Draw
public void Draw(GameTime dt)
{
Game.Game.Sprites.Begin();
Game.Game.Sprites.Draw(background, new Rectangle(0, 0,
sizex, sizey), Color.White);
Game.Game.Sprites.End();
}
示例4: Update
public override void Update(GameTime gameTime)
{
if (Updates)
{
foreach (Entity e in Entities) e.Update(gameTime, Entities[2] as FlyingDisc);
}
}
示例5: Update
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
if (waitTime > 0) //Als hij moet wachten voor het draaien
{
waitTime -= (float)gameTime.ElapsedGameTime.TotalSeconds;
if (waitTime <= 0.0f)
TurnAround();
}
else
{
TileField tiles = GameWorld.Find("tiles") as TileField;
float posX = this.BoundingBox.Left;
if (!Mirror)
posX = this.BoundingBox.Right;
int tileX = (int)Math.Floor(posX / tiles.CellWidth);
int tileY = (int)Math.Floor(position.Y / tiles.CellHeight);
//Hij moet wachten als hij aan het einde is van zijn plankje en dan moet hij zich omdraaien
if (tiles.GetTileType(tileX, tileY - 1) == TileType.Normal ||
tiles.GetTileType(tileX, tileY) == TileType.Background)
{
waitTime = 0.5f;
velocity.X = 0.0f;
}
}
this.CheckPlayerCollision();
}
示例6: Draw
/// <summary>
/// Draws the menu.
/// </summary>
public override void Draw(GameTime gameTime)
{
// make sure our entries are in the right place before we draw them
UpdateMenuEntryLocations();
SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
SpriteFont font = ScreenManager.Fonts.MenuSpriteFont;
spriteBatch.Begin();
// Draw each menu entry in turn.
for (int i = 0; i < _menuEntries.Count; ++i)
{
bool isSelected = IsActive && (i == _selectedEntry);
_menuEntries[i].Draw();
}
// Make the menu slide into place during transitions, using a
// power curve to make things look more interesting (this makes
// the movement slow down as it nears the end).
Vector2 transitionOffset = new Vector2(0f, (float)Math.Pow(TransitionPosition, 2) * 100f);
spriteBatch.DrawString(font, _menuTitle, _titlePosition - transitionOffset + Vector2.One * 2f, Color.Black, 0,
_titleOrigin, 1f, SpriteEffects.None, 0);
spriteBatch.DrawString(font, _menuTitle, _titlePosition - transitionOffset, new Color(255, 210, 0), 0,
_titleOrigin, 1f, SpriteEffects.None, 0);
_scrollUp.Draw();
_scrollSlider.Draw();
_scrollDown.Draw();
spriteBatch.End();
}
示例7: Update
public void Update(GameTime gameTime)
{
this.CurrentCampaign.Update(
gameTime.ElapsedGameTime,
gameTime.TotalGameTime,
gameTime.IsRunningSlowly);
}
示例8: ExecuteQueue
/// <summary>
/// Executes enqueued commands. Updates delayed commands.
/// </summary>
/// <param name="gameTime"></param>
public void ExecuteQueue( GameTime gameTime, bool forceDelayed = false )
{
var delta = (int)gameTime.Elapsed.TotalMilliseconds;
lock (lockObject) {
delayed.Clear();
while (queue.Any()) {
var cmd = queue.Dequeue();
if (cmd.Delay<=0 || forceDelayed) {
// execute :
cmd.Execute();
// push to history :
if (!cmd.NoRollback) {
history.Push( cmd );
}
} else {
cmd.Delay -= delta;
delayed.Enqueue( cmd );
}
}
Misc.Swap( ref delayed, ref queue );
}
}
示例9: Draw
/// <summary>
/// Draws the objects in the list
/// </summary>
/// <param name="gameTime">The object used for reacting to timechanges</param>
/// <param name="spriteBatch">The SpriteBatch</param>
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
if (!visible)
return;
foreach(GameObject obj in gameObjects)
obj.Draw(gameTime, spriteBatch);
}
示例10: Initialize
static void Initialize()
{
if (!theGameTime) {
GameObject go = new GameObject("GameTime");
theGameTime = go.AddComponent(typeof(GameTime)) as GameTime;
}
}
示例11: Draw
protected override void Draw(GameTime time)
{
base.Draw(time);
GraphicsDevice.Clear(new Color(32, 32, 32, 0));
Sprite.Begin(SpriteSortMode.Deferred, GraphicsDevice.BlendStates.NonPremultiplied);
Sprite.DrawString(font, "FPS: " + FPS.ToString("#"), new Vector2(10, 10), Color.Lime);
Sprite.DrawString(font, "Keyboard: " + Keyboard, new Vector2(10, 40), Color.Gray);
Sprite.DrawString(font, "Mouse: " + Mouse, new Vector2(10, 70), Color.Gray);
Sprite.DrawString(font, "Window: " + Width + "x" + Height, new Vector2(10, 100), Color.Gray);
effect.VertexColorEnabled = true;
effect.CurrentTechnique.Passes[0].Apply();
lineVertex.Begin();
lineVertex.DrawLine(
new VertexPositionColor(new Vector3(50, 0, 0), Color.White),
new VertexPositionColor(new Vector3(-50, 0, 0), Color.White));
lineVertex.DrawLine(
new VertexPositionColor(new Vector3(0, 50, 0), Color.Red),
new VertexPositionColor(new Vector3(0, -50, 0), Color.Red));
lineVertex.End();
Sprite.End();
}
示例12: Draw
public override void Draw(GameTime gameTime)
{
spriteBatch.Begin();
spriteBatch.Draw(texture, playerBody.Position, null, Color.White, playerBody.Rotation, new Vector2(WIDTH, HEIGHT) / 2.0f, 1.0f, SpriteEffects.None, 0.0f);
spriteBatch.End();
base.Draw(gameTime);
}
示例13: Effect
public Effect(GameTime gameTime, Vector2 position, EffectPosition height, VGame.Shape shape)
{
_position = position;
Height = height;
Shape = shape;
ExpirationTime = gameTime.TotalGameTime + Duration;
}
示例14: Draw
public override void Draw( GameTime gameTime )
{
ScreenManager.SpriteBatch.Begin( 0, null, null, null, null, null, Camera.View );
// draw car
ScreenManager.SpriteBatch.Draw( _wheel.Texture, ConvertUnits.ToDisplayUnits( _wheelBack.Position ), null,
Color.White, _wheelBack.Rotation, _wheel.Origin, _scale, SpriteEffects.None,
0f );
ScreenManager.SpriteBatch.Draw( _wheel.Texture, ConvertUnits.ToDisplayUnits( _wheelFront.Position ), null,
Color.White, _wheelFront.Rotation, _wheel.Origin, _scale, SpriteEffects.None,
0f );
ScreenManager.SpriteBatch.Draw( _carBody.Texture, ConvertUnits.ToDisplayUnits( _car.Position ), null,
Color.White, _car.Rotation, _carBody.Origin, _scale, SpriteEffects.None, 0f );
// draw teeter
ScreenManager.SpriteBatch.Draw( _teeter.Texture, ConvertUnits.ToDisplayUnits( _board.Position ), null,
Color.White, _board.Rotation, _teeter.Origin, 1f, SpriteEffects.None, 0f );
// draw bridge
for ( int i = 0; i < _bridgeSegments.Count; ++i ) {
ScreenManager.SpriteBatch.Draw( _bridge.Texture, ConvertUnits.ToDisplayUnits( _bridgeSegments[ i ].Position ),
null,
Color.White, _bridgeSegments[ i ].Rotation, _bridge.Origin, 1f,
SpriteEffects.None, 0f );
}
// draw boxes
for ( int i = 0; i < _boxes.Count; ++i ) {
ScreenManager.SpriteBatch.Draw( _box.Texture, ConvertUnits.ToDisplayUnits( _boxes[ i ].Position ), null,
Color.White, _boxes[ i ].Rotation, _box.Origin, 1f, SpriteEffects.None, 0f );
}
// draw ground
ScreenManager.SpriteBatch.Draw( _groundTex, ConvertUnits.ToDisplayUnits( _ground.Position ), null, Color.White, _ground.Rotation, _groundOrigin, _mapScale, SpriteEffects.None, 0f );
ScreenManager.SpriteBatch.End();
base.Draw( gameTime );
}
示例15: Draw
protected override void Draw(GameTime aGameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
theFileManager.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
theScreenManager.Draw(aGameTime);
theFileManager.SpriteBatch.End();
}