示例#1
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            Application.FrameRate = gameTime.ElapsedGameTime.TotalSeconds;
            TickManager.Update();
        }
示例#2
0
        public static Actor Spawn(string typeName, Vector2 position)
        {
            var actor = TickManager.Create(GameObjectNameSpace + typeName) as Actor;

            Debug.Assert(actor != null, "Cannot create actor.");

            if (actor.Transform.Position == Transform.Default.Position)
            {
                actor.Transform.Position = new Vector2(position.X, position.Y);
            }

            TickManager.Spawn(actor);

            return(actor);
        }
示例#3
0
        public static T Spawn <T>(Vector2 position, float rotation = 0, float scale = 1) where T : Actor, new()
        {
            var actor = TickManager.Create <T>();

            if (actor.Transform.Position == Transform.Default.Position)
            {
                actor.Transform.Position = position;
            }
            if (actor.Transform.Rotation == Transform.Default.Rotation)
            {
                actor.Transform.Rotation = rotation;
            }
            if (actor.Transform.Scale == Transform.Default.Scale)
            {
                actor.Transform.Scale = scale;
            }
            TickManager.Spawn(actor);

            return(actor);
        }
示例#4
0
        protected override void Initialize()
        {
            base.Initialize();
            IsMouseVisible = true;

            Application.GraphicsDevice = GraphicsDevice;
            Application.SpriteBatch    = new SpriteBatch(GraphicsDevice);

            Application.GraphicsDeviceManager = graphics;
            Application.Content = Content;

            var viewportAdapter = new BoxingViewportAdapter(
                Window,
                GraphicsDevice,
                graphics.PreferredBackBufferWidth / 16,
                graphics.PreferredBackBufferHeight / 16);

            Application.ViewportAdapter = viewportAdapter;
            Application.MainCamera      = new Camera2D(viewportAdapter);

            TickManager.Spawn <StartScene>();
        }
示例#5
0
 public static void Destroy(Actor actor)
 {
     TickManager.Destroy(actor);
 }