Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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>();
        }