protected override void Update(GameTime gameTime) { base.Update(gameTime); if (Input.IsKeyPressed(Keys.W)) textBlock.WrapText = !textBlock.WrapText; if (Input.IsKeyPressed(Keys.R)) { textBlock.VerticalAlignment = VerticalAlignment.Stretch; textBlock.HorizontalAlignment = HorizontalAlignment.Stretch; } if (Input.IsKeyReleased(Keys.NumPad1)) textBlock.VerticalAlignment = VerticalAlignment.Top; if (Input.IsKeyReleased(Keys.NumPad2)) textBlock.VerticalAlignment = VerticalAlignment.Center; if (Input.IsKeyReleased(Keys.NumPad3)) textBlock.VerticalAlignment = VerticalAlignment.Bottom; if (Input.IsKeyReleased(Keys.NumPad4)) textBlock.HorizontalAlignment = HorizontalAlignment.Left; if (Input.IsKeyReleased(Keys.NumPad5)) textBlock.HorizontalAlignment = HorizontalAlignment.Center; if (Input.IsKeyReleased(Keys.NumPad6)) textBlock.HorizontalAlignment = HorizontalAlignment.Right; if (Input.IsKeyReleased(Keys.NumPad7)) textBlock.TextAlignment = TextAlignment.Left; if (Input.IsKeyReleased(Keys.NumPad8)) textBlock.TextAlignment = TextAlignment.Center; if (Input.IsKeyReleased(Keys.NumPad9)) textBlock.TextAlignment = TextAlignment.Right; }
public override void Update(GameTime gameTime) { if (Simulation.DisableSimulation) return; lock (this) { //read skinned meshes bone positions foreach (var physicsScene in scenes) { //read skinned meshes bone positions and write them to the physics engine physicsScene.Processor.UpdateBones(); //simulate physics physicsScene.Simulation.Simulate((float)gameTime.Elapsed.TotalSeconds); //update character bound entity's transforms from physics engine simulation physicsScene.Processor.UpdateCharacters(); physicsScene.Simulation.BeginContactTesting(); //finally process any needed cleanup physicsScene.Processor.UpdateRemovals(); //handle frame contacts physicsScene.Processor.UpdateContacts(); physicsScene.Simulation.EndContactTesting(); //send contact events physicsScene.Simulation.SendEvents(); } } }
/// <inheritdoc/> public override void Update(GameTime time) { base.Update(time); if (ManageShadows) { InternalActiveShadowMaps.Clear(); InternalActiveShadowMapTextures.Clear(); foreach (var light in Lights) { // create new shadow maps if (light.Value.Light.Shadow != null) CreateShadowMap(light.Value); // TODO: handle shadow maps that does no require to be updated like static shadow maps. // update shadow maps info if (light.Value.Light.Enabled && light.Value.Light.Shadow != null && light.Value.Light.Shadow.Enabled && light.Value.ShadowMap.Update) { UpdateEntityLightShadow(light.Value); InternalActiveShadowMaps.Add(light.Value.ShadowMap); InternalActiveShadowMapTextures.Add(light.Value.ShadowMap.Texture); } } } }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (Input.IsKeyReleased(Keys.W)) textScroller.RepeatText = !textScroller.RepeatText; if (Input.IsKeyDown(Keys.Right)) textScroller.ScrollingSpeed /= 1.1f; if (Input.IsKeyDown(Keys.Left)) textScroller.ScrollingSpeed *= 1.1f; if (Input.IsKeyReleased(Keys.C)) textScroller.ClearText(); if (Input.IsKeyReleased(Keys.T)) textScroller.Text = TextWithBlanks; if (Input.IsKeyReleased(Keys.A)) textScroller.AppendText(" Additional Text"); if (Input.IsKeyReleased(Keys.B)) IncreaseButtonSize(); if (Input.IsKeyReleased(Keys.V)) DecreaseButtonSize(); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (Input.IsKeyReleased(Keys.D1)) scrollViewer.Content = grid; if (Input.IsKeyReleased(Keys.D2)) scrollViewer.Content = stackPanel; if (Input.IsKeyReleased(Keys.NumPad4)) scrollViewer.ScrollToBeginning(Orientation.Horizontal); if (Input.IsKeyReleased(Keys.NumPad6)) scrollViewer.ScrollToEnd(Orientation.Horizontal); if (Input.IsKeyReleased(Keys.NumPad8)) scrollViewer.ScrollToBeginning(Orientation.Vertical); if (Input.IsKeyReleased(Keys.NumPad2)) scrollViewer.ScrollToEnd(Orientation.Vertical); if (Input.IsKeyReleased(Keys.V)) scrollViewer.ScrollMode = ScrollingMode.Vertical; if (Input.IsKeyReleased(Keys.H)) scrollViewer.ScrollMode = ScrollingMode.Horizontal; if (Input.IsKeyReleased(Keys.B)) scrollViewer.ScrollMode = ScrollingMode.HorizontalVertical; if (Input.IsKeyReleased(Keys.Space)) // check that scroll offsets are correctly updated when content gets smaller (and we are at the end of document) grid.Height = float.IsNaN(grid.Height) ? 100 : float.NaN; if (Input.IsKeyReleased(Keys.Enter)) // check that scrolling works even when IsArrange is false (try this when ScrollMode is in Horizontal mode) { grid.Height = 1000; scrollViewer.ScrollMode = ScrollingMode.Vertical; scrollViewer.ScrollToEnd(Orientation.Vertical); } }
protected override void Update(GameTime gameTime) { base.Update(gameTime); const float ChangeFactor = 1.1f; const float ChangeFactorInverse = 1 / ChangeFactor; // change the size of the virtual resolution if (Input.IsKeyReleased(Keys.NumPad0)) UIComponent.VirtualResolution = new Vector3(GraphicsDevice.BackBuffer.Width / 2f, GraphicsDevice.BackBuffer.Height / 2f, 400); if (Input.IsKeyReleased(Keys.NumPad1)) UIComponent.VirtualResolution = new Vector3(GraphicsDevice.BackBuffer.Width, GraphicsDevice.BackBuffer.Height, 400); if (Input.IsKeyReleased(Keys.NumPad2)) UIComponent.VirtualResolution = new Vector3(2 * GraphicsDevice.BackBuffer.Width, 2 * GraphicsDevice.BackBuffer.Height, 400); if (Input.IsKeyReleased(Keys.Right)) UIComponent.VirtualResolution = new Vector3((ChangeFactor * UIComponent.VirtualResolution.X), UIComponent.VirtualResolution.Y, UIComponent.VirtualResolution.Z); if (Input.IsKeyReleased(Keys.Left)) UIComponent.VirtualResolution = new Vector3((ChangeFactorInverse * UIComponent.VirtualResolution.X), UIComponent.VirtualResolution.Y, UIComponent.VirtualResolution.Z); if (Input.IsKeyReleased(Keys.Up)) UIComponent.VirtualResolution = new Vector3(UIComponent.VirtualResolution.X, (ChangeFactor * UIComponent.VirtualResolution.Y), UIComponent.VirtualResolution.Z); if (Input.IsKeyReleased(Keys.Down)) UIComponent.VirtualResolution = new Vector3(UIComponent.VirtualResolution.X, (ChangeFactorInverse * UIComponent.VirtualResolution.Y), UIComponent.VirtualResolution.Z); if (Input.IsKeyReleased(Keys.D1)) decorator.LocalMatrix = Matrix.Scaling(1); if (Input.IsKeyReleased(Keys.D2)) decorator.LocalMatrix = Matrix.Scaling(1.5f); if (Input.IsKeyReleased(Keys.D3)) decorator.LocalMatrix = Matrix.Scaling(2); }
public override void Update(GameTime gameTime) { if (SceneInstance != null) { SceneInstance.Update(gameTime); } }
protected override void Draw(GameTime gameTime) { base.Draw(gameTime); if(!ScreenShotAutomationEnabled) DrawCustomEffect(); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (Input.IsKeyReleased(Keys.S)) SaveTexture(GraphicsDevice.Presenter.BackBuffer, "sprite-font-extern-test.png"); }
protected override void Draw(GameTime gameTime) { base.Draw(gameTime); //var time = (float)gameTime.Total.TotalSeconds; //cubeEntity.Transform.Rotation = Quaternion.RotationY(time) * Quaternion.RotationX(time * 0.5f); }
protected override void Draw(GameTime gameTime) { base.Draw(gameTime); if (!ScreenShotAutomationEnabled) DrawSprites(); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); const float depthIncrement = 1f; const float rotationIncrement = 0.1f; var localMatrix = elements[1].LocalMatrix; if (Input.IsKeyPressed(Keys.Up)) localMatrix.M43 -= depthIncrement; if (Input.IsKeyPressed(Keys.Down)) localMatrix.M43 += depthIncrement; if (Input.IsKeyPressed(Keys.NumPad4)) localMatrix = localMatrix * Matrix.RotationY(-rotationIncrement); if (Input.IsKeyPressed(Keys.NumPad6)) localMatrix = localMatrix * Matrix.RotationY(+rotationIncrement); if (Input.IsKeyPressed(Keys.NumPad2)) localMatrix = localMatrix * Matrix.RotationX(+rotationIncrement); if (Input.IsKeyPressed(Keys.NumPad8)) localMatrix = localMatrix * Matrix.RotationX(-rotationIncrement); if (Input.IsKeyPressed(Keys.NumPad1)) localMatrix = localMatrix * Matrix.RotationZ(-rotationIncrement); if (Input.IsKeyPressed(Keys.NumPad9)) localMatrix = localMatrix * Matrix.RotationZ(+rotationIncrement); if (Input.KeyEvents.Any()) { elements[1].LocalMatrix = localMatrix; UpdateTextBlockText(); } }
protected override void Draw(GameTime gameTime) { base.Draw(gameTime); if (!ScreenShotAutomationEnabled) RenderToTexture(); }
public override void Draw(GameTime gameTime) { if (SceneInstance == null || MainRenderFrame == null) { return; } // If the width or height changed, we have to recycle all temporary allocated resources. // NOTE: We assume that they are mostly resolution dependent. if (previousWidth != MainRenderFrame.Width || previousHeight != MainRenderFrame.Height) { // Force a recycle of all allocated temporary textures renderContext.Allocator.Recycle(link => true); } previousWidth = MainRenderFrame.Width; previousHeight = MainRenderFrame.Height; // Update the entities at draw time. renderContext.Time = gameTime; SceneInstance.Draw(renderContext); // Renders the scene SceneInstance.Draw(renderContext, MainRenderFrame); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (Input.IsKeyReleased(Keys.D1)) element1.ClipToBounds = !element1.ClipToBounds; if (Input.IsKeyReleased(Keys.D2)) element2.ClipToBounds = !element2.ClipToBounds; if (Input.IsKeyReleased(Keys.D3)) element3.ClipToBounds = !element3.ClipToBounds; if (Input.IsKeyReleased(Keys.D4)) element4.ClipToBounds = !element4.ClipToBounds; if (Input.IsKeyDown(Keys.Left)) element3.LocalMatrix = Matrix.Translation(element3.LocalMatrix.TranslationVector - Vector3.UnitX); if (Input.IsKeyDown(Keys.Right)) element3.LocalMatrix = Matrix.Translation(element3.LocalMatrix.TranslationVector + Vector3.UnitX); if (Input.IsKeyDown(Keys.Up)) element3.LocalMatrix = Matrix.Translation(element3.LocalMatrix.TranslationVector - Vector3.UnitY); if (Input.IsKeyDown(Keys.Down)) element3.LocalMatrix = Matrix.Translation(element3.LocalMatrix.TranslationVector + Vector3.UnitY); if (Input.IsKeyDown(Keys.NumPad7)) MoveElementToLeftTopCorner(); if (Input.IsKeyDown(Keys.NumPad9)) MoveElementToRightTopCorner(); if (Input.IsKeyDown(Keys.NumPad5)) MoveElementToIntersection(); if (Input.IsKeyDown(Keys.NumPad3)) MoveElementToRightBottomCorner(); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (Input.KeyEvents.Count > 0) toggle.IsThreeState = !toggle.IsThreeState; }
partial void PickingUpdate(RenderUIElement renderUIElement, Viewport viewport, ref Matrix worldViewProj, GameTime drawTime) { if (renderUIElement.UIComponent.Page?.RootElement == null) return; UpdateMouseOver(ref viewport, ref worldViewProj, renderUIElement); UpdateTouchEvents(ref viewport, ref worldViewProj, renderUIElement, drawTime); }
public void ManualUpdates(double elapsedSeconds, int updateTimes) { var elapsedSpan = TimeSpan.FromSeconds(elapsedSeconds); var gameTime = new GameTime(elapsedSpan, elapsedSpan); for (int i = 0; i < updateTimes; i++) base.Update(gameTime); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (Input.IsKeyDown(Keys.Escape)) { Exit(); } }
protected override void Draw(GameTime gameTime) { if (!ScreenShotAutomationEnabled) AdjustEffectParameters(); DrawCustomEffect(); base.Draw(gameTime); }
protected override void Draw(GameTime gameTime) { base.Draw(gameTime); accumulatedSeconds += 1 / 60f; if(!ScreenShotAutomationEnabled) DrawText(); }
protected override void Draw(GameTime gameTime) { base.Draw(gameTime); timeInSeconds += 1 / 60f; // frame dependent for graphic unit testing. if (!ScreenShotAutomationEnabled) DrawScene(); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (Input.IsKeyReleased(Keys.Left)) spriteBatch.VirtualResolution = 3 / 4f * spriteBatch.VirtualResolution; if (Input.IsKeyReleased(Keys.Right)) spriteBatch.VirtualResolution = 4 / 3f * spriteBatch.VirtualResolution; }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (Input.IsKeyPressed(Keys.NumPad1)) samplesCount = Math.Max(1, samplesCount / 2); if (Input.IsKeyPressed(Keys.NumPad3)) samplesCount = Math.Min(1024, samplesCount * 2); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (Input.IsKeyPressed(Keys.I)) displayedTexture = inputTexture; if (Input.IsKeyPressed(Keys.O)) displayedTexture = outputTexture; }
protected override void Update(GameTime gameTime) { LoadContent().Wait(); BeforeUpdating?.Invoke(this); base.Update(gameTime); AfterUpdating?.Invoke(this); }
protected override void Draw(GameTime gameTime) { LoadContent().Wait(); BeforeDrawing?.Invoke(this); base.Draw(gameTime); AfterDrawing?.Invoke(this); }
protected override void Draw(GameTime gameTime) { if (!ScreenShotAutomationEnabled) AdjustEffectParameters(); var renderDrawContext = new RenderDrawContext(Services, RenderContext.GetShared(Services), GraphicsContext); DrawCustomEffect(renderDrawContext); base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { base.Draw(gameTime); var elapsedTime = gameTime.Elapsed.TotalSeconds; foreach (var sprite in playingSprites) { if(sprite.IsPaused) continue; sprite.ElapsedTime += elapsedTime; // As long as we have some animations to play for the given sprite... while (sprite.Animations.Count > 0) { var animationInfo = sprite.Animations.Peek(); var oneFrameTime = 1 / animationInfo.FramePerSeconds; // As long as needed and possible go to the next animation frame while (sprite.ElapsedTime >= oneFrameTime && (animationInfo.ShouldLoop || sprite.CurrentIndexIndex < animationInfo.SpriteIndices.Count-1)) { sprite.ElapsedTime -= oneFrameTime; sprite.CurrentIndexIndex = (sprite.CurrentIndexIndex + 1) % animationInfo.SpriteIndices.Count; } // set the sprite frame sprite.CurrentFrame = animationInfo.SpriteIndices[sprite.CurrentIndexIndex]; // we reached the end of the animation -> go to next animation if (sprite.ElapsedTime >= oneFrameTime) { sprite.ElapsedTime -= oneFrameTime; // consider that one frame elapse between the two animations sprite.RecycleFirstAnimation(); } else // animation is not finished yet -> exit loop { break; } } // There is no more animations to play for this sprite -> remove it from the sprite to animate list if (sprite.Animations.Count == 0) spritesToStop.Add(sprite); } // actually stops the sprites that have finished their animation foreach (var spriteComponent in spritesToStop) { playingSprites.Remove(spriteComponent); spriteComponent.CurrentIndexIndex = 0; spriteComponent.ElapsedTime = 0; } spritesToStop.Clear(); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (IsAutomatic) { zValue = 100 * (1 + (float)Math.Sin(gameTime.Total.TotalSeconds)); element1.LocalMatrix = Matrix.Translation(0, 0, zValue); } }