private void OnShown(object sender, EventArgs e)
        {
            previewGame = new AnimationGame(pictureBox_AnimationPreview.Handle, this, pictureBox_AnimationPreview, new Vector2(pictureBox_AnimationPreview.Width, pictureBox_AnimationPreview.Height));
            previewManager = new GraphicsManager(previewGame.gameGraphics);
            previewGame.gameForm.GotFocus += delegate(object o, EventArgs args)
            {
                this.Focus();
            };
            previewGame.gameGraphics.GraphicsManager.DeviceCreated += delegate(object o, EventArgs args)
            {
                previewGame.gameGraphics.AddTexture(animationTexture.Name, TextureManager.ConvertDataToTexture(animationTexture, previewGame.GraphicsDevice));
                previewGame.gameGraphics.AddDrawable(previewAnimation);
                Vector2 center = StaticMethods.GetCenter(new Vector2(previewAnimation.Frames[1].TextureSource.Width,previewAnimation.Frames[1].TextureSource.Height));
                Vector2 position = StaticMethods.GetDrawPosition(new Vector2(panel_AnimationPreview.Width, panel_AnimationPreview.Height), center);
                previewGame.gameGraphics.AddToDrawList(new DrawParam(previewAnimation.Name, previewAnimation.Name,position, DrawnType.Animation));
                LoopAction loopActon = new LoopAction
                {
                    Name = previewAnimation.Name,
                    Drawable = previewAnimation.Name,
                    Value = true
                };
                previewManager.ExecuteAction(loopActon);

            };
            previewGame.Run();
        }
Exemplo n.º 2
0
        static void Main()
        {
            MainEditorWindow mainWindow = new MainEditorWindow();

            mainWindow.Show();

            BaseGame.DrawSurface = mainWindow.GetGameWindowHandle();
            AnimationGame game = new AnimationGame();

            ((AnimationGame)game).Render = mainWindow.Render;
            game.Run();
        }
Exemplo n.º 3
0
 private void MainWindow_Shown(object sender, EventArgs e)
 {
     Game = new AnimationGame(picBox_AnimationPreview.Handle, this, picBox_AnimationPreview, new Vector2(0, 0));
     Game.gameGraphics.GraphicsManager.DeviceCreated += delegate(object gsender, EventArgs gargs)
     {
         graphicsManager = new GraphicsManager(Game.gameGraphics);
     };
     Game.Run();
 }
        //Same as LoadFrameGame, but you're able to run some stuff before starting the game. This way things for the game can be created, but  other things can be done right before we start the game since nothing can be done after less it be an event
        private void LoadFrameGame(Action action)
        {
            _frameGame = new AnimationGame(pictureBox_FrameDisplay.Handle, this, pictureBox_FrameDisplay, new Vector2(pictureBox_FrameDisplay.Width, pictureBox_FrameDisplay.Height));
            animationManager = new GraphicsManager(_frameGame.gameGraphics);
            pictureBox_TextureDisplay.Width = _frameGame.gameGraphics.GraphicsManager.PreferredBackBufferWidth;
            pictureBox_TextureDisplay.Height = _frameGame.gameGraphics.GraphicsManager.PreferredBackBufferHeight;

            _frameGame.gameForm.GotFocus += delegate(object o, EventArgs args)
            {
                this.Focus();
            };
            _frameGameLoaded = true;
            _frameGame.gameGraphics.GraphicsManager.DeviceCreated += delegate(object o, EventArgs args)
            {
                foreach (BinaryTexture texture in _binaryTextures)
                {
                    _frameGame.gameGraphics.textureManager.Textures.Add(texture.Name, TextureManager.ConvertDataToTexture(texture, _frameGame.gameGraphics.GraphicsManager.GraphicsDevice));
                }
            };
            Vector2 position = Vector2.Zero;
            if (ReturnAnimation.Frames[1].TextureSource.Width <= panel_FrameDisplay.Width || ReturnAnimation.Frames[1].TextureSource.Height <= panel_FrameDisplay.Height)
            {
                Vector2 center = StaticMethods.GetCenter(new Vector2(((ReturnAnimation.Frames[1].TextureSource.Width) * ReturnAnimation.Scale), (ReturnAnimation.Frames[1].TextureSource.Height) * ReturnAnimation.Scale));
                position = StaticMethods.GetDrawPosition(new Vector2(panel_FrameDisplay.Width, panel_FrameDisplay.Height), center);
            }
            _frameGame.gameGraphics.AddDrawable(ReturnAnimation);
            _frameGame.gameGraphics.AddToDrawList(new DrawParam(ReturnAnimation.Name, ReturnAnimation.Name, position, DrawnType.Animation));
            action();
            _frameGame.Run();
        }