本文整理汇总了C#中GameTime类的典型用法代码示例。如果您正苦于以下问题:C# GameTime类的具体用法?C# GameTime怎么用?C# GameTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GameTime类属于命名空间,在下文中一共展示了GameTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:hilts-vaughan,项目名称:Farseer-Physics,代码行数:26,代码来源:Game.cs
示例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);
}
开发者ID:AnthonyNeace,项目名称:xna-snake,代码行数:25,代码来源:ResizeAndGrid.cs
示例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();
}
开发者ID:spdemille,项目名称:Baffled,代码行数:7,代码来源:Screen.cs
示例4: Update
public override void Update(GameTime gameTime)
{
if (Updates)
{
foreach (Entity e in Entities) e.Update(gameTime, Entities[2] as FlyingDisc);
}
}
开发者ID:jwogolf,项目名称:PsychedelicFrisbeeHospital-WP8,代码行数:7,代码来源:GameScreen.cs
示例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();
}
开发者ID:TheHappyCow,项目名称:TickTick,代码行数:27,代码来源:PatrollingEnemy.cs
示例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();
}
开发者ID:AdamNThompson,项目名称:Farseer-MonoGame-WinGL,代码行数:33,代码来源:MenuScreen.cs
示例7: Update
public void Update(GameTime gameTime)
{
this.CurrentCampaign.Update(
gameTime.ElapsedGameTime,
gameTime.TotalGameTime,
gameTime.IsRunningSlowly);
}
开发者ID:robertkety,项目名称:Hero6,代码行数:7,代码来源:CampaignHandler.cs
示例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 );
}
}
开发者ID:temik911,项目名称:audio,代码行数:37,代码来源:Invoker.cs
示例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);
}
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:12,代码来源:GameObjectList.cs
示例10: Initialize
static void Initialize()
{
if (!theGameTime) {
GameObject go = new GameObject("GameTime");
theGameTime = go.AddComponent(typeof(GameTime)) as GameTime;
}
}
开发者ID:Diggery,项目名称:IronClad,代码行数:7,代码来源:GameTime.cs
示例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();
}
开发者ID:mimic2300,项目名称:WormsGame,代码行数:27,代码来源:WormsGameWindow.cs
示例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);
}
开发者ID:northdocks,项目名称:ggj-2012-splash-damage,代码行数:7,代码来源:jumpAndRunPlayerFigure.cs
示例13: Effect
public Effect(GameTime gameTime, Vector2 position, EffectPosition height, VGame.Shape shape)
{
_position = position;
Height = height;
Shape = shape;
ExpirationTime = gameTime.TotalGameTime + Duration;
}
开发者ID:adamrezich,项目名称:arena,代码行数:7,代码来源:Effect.cs
示例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 );
}
开发者ID:headdetect,项目名称:Circular,代码行数:35,代码来源:LevelTutorial.cs
示例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();
}
开发者ID:JonathanMcCaffrey,项目名称:tank-gauntlet,代码行数:7,代码来源:Game1.cs
示例16: feet
private double tide_ft; // Measurement in feet (convert to meter -> tide_mt = tide_ft * 0.3048)
// Period (p): horizontal distance before the y-axis begins to repeat
// Frequency (f): number of complete waves for a given time Period
// p = 2pi/f
void Awake () {
gameTime = GameObject.Find("HUDGameTime").GetComponent<GameTime>();
water_Y_axis = water.GetComponent<Transform>();
rand = new System.Random();
frequency = (2.619278 + 0.5 * Math.PI) / 8;
}
开发者ID:FIU-SCIS-Senior-Projects,项目名称:UrbanTheater,代码行数:12,代码来源:SeaLevelManager.cs
示例17: Update
public void Update(GameTime t)
{
ConstructionBuilding target = this.Destination as ConstructionBuilding;
if (target != null)
{
// arrived at destination
if (path.Count == 0)
{
// work on current target building
target.ConstructionTime -= (float)t.ElapsedGameTime.TotalSeconds;
if (target.ConstructionTime <= 0)
{
// request moving to idle list
BunkaGame.ConstructionManager.MoveToIdle(this);
// signal that construction is finished
BunkaGame.ConstructionManager.CompleteConstruction(target);
// reset target
this.Destination = null;
this.path = null;
}
}
else
{
UpdateAimAndVelocity();
this.Position += this.Aim * this.Velocity;
}
}
}
开发者ID:jlvermeulen,项目名称:bunka,代码行数:30,代码来源:Builder.cs
示例18: Update
public void Update(GameTime gameTime)
{
currentTime = (float)gameTime.TotalGameTime.TotalMilliseconds;
deltaTime = currentTime - lastTime;
lastTime = currentTime;
myFPS = (int)(1.0 / (.001 * deltaTime));
}
开发者ID:Dahrkael,项目名称:CoRe,代码行数:7,代码来源:FPSCounter.cs
示例19: Draw
public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
this.CurrentCampaign.Draw(
gameTime.ElapsedGameTime,
gameTime.TotalGameTime,
gameTime.IsRunningSlowly);
}
开发者ID:robertkety,项目名称:Hero6,代码行数:7,代码来源:CampaignHandler.cs
示例20: Update
/// <summary>Updatethe button.</summary>
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
spr_lock.Visible = level.Locked;
levels_solved.Visible = level.Solved;
levels_unsolved.Visible = !level.Solved;
}
开发者ID:alikimoko,项目名称:Practicum3.Platformer,代码行数:8,代码来源:LevelButton.cs
注:本文中的GameTime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论