示例#1
0
        protected override void Update(GameTime gameTime)
        {
            KeyboardState ks = new KeyboardState();

            Keys[] keys = ks.GetPressedKeys();

            if (ks.IsKeyUp(lastKey))
            {
                lastKey = Keys.None;
            }

            if (keys.Length > 0 && lastKey == Keys.None)
            {
                lastKey = keys[0];
                var keyValue = keys[0].ToString();
                Sgml.keyboard_string += keyValue;
            }

            MousePositionTranslated = cam.Camera.ScreenToWorld(MousePosition);
            GridSizeRender          = new Vector2(SimplexMath.Lerp(GridSizeRender.X, GridSize.X, 0.2f), SimplexMath.Lerp(GridSizeRender.Y, GridSize.Y, 0.2f));

            Input.KeyboardState = ks;

            g = gameTime;
            base.Update(gameTime);

            cam.UpdatePosition();

            foreach (RoomLayer rl in roomLayers)
            {
                if (rl.Visible)
                {
                    if (rl is ObjectLayer)
                    {
                        foreach (GameObject o in ((ObjectLayer)rl).Objects)
                        {
                            if (o.Position.X != o.PositionPrevious.X || o.Position.Y != o.PositionPrevious.Y)
                            {
                                sh.UnregisterObject(o);
                                sh.RegisterObject(o);
                            }

                            if (GameRunning || o == clickedObject)
                            {
                                o.EvtStep();
                            }
                        }
                    }
                }
            }
        }