是否有一个SharpDx模板,为Windows通用应用程序? [英] Is there a SharpDx Template, for a Windows Universal App?

查看:252
本文介绍了是否有一个SharpDx模板,为Windows通用应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着写一个游戏的Windows和Windows Phone 8.1,与SharpDx。但是,当我尝试,在Windows Phone的版本8.1添加到我现有的Windows 8.1的比赛,我得到了一些错误和App不起作用。现在的问题:是否有SharpDx模板在XNA风格为Windows通用的应用程序,就像我得到了我唯一的Windows 8.1游戏的模板(从SharpDx的Visual Studio扩展)

I tried to write a game for Windows and Windows Phone 8.1, with SharpDx. But when I try, to add a Windows Phone 8.1 Version to my already existing Windows 8.1 Game, I get a few errors and the App doesn't work. Now the question: Is there an SharpDx Template in XNA Style for a Windows Universal App, like the Template I got for my only Windows 8.1 Game (from the SharpDx Visual Studio Extension)?

推荐答案

没有没有,没有。

你应该做的是开放的问题( https://github.com/sharpdx/SharpDX/issues ),并要求该功能。要实施

What you should do is open an issue (https://github.com/sharpdx/SharpDX/issues) and ask for the feature to be implemented.

但是你仍然可以上手,而等待它执行:D

下面就是我想你的情况:

Here's how I tried your scenario:


  • 创建一个通用的应用程序项目

  • SharpDX.Toolkit.Game的NuGet包添加到每个设备项目( HOWTO

  • create a Universal App project
  • add the SharpDX.Toolkit.Game NuGet package to each of your device project (howto)

然后在你的共享项目

添加您的游戏:

using SharpDX;
using SharpDX.Toolkit;

namespace App1 {
    internal class MyGame : Game {
        private GraphicsDeviceManager _manager;

        public MyGame() {
            _manager = new GraphicsDeviceManager(this);
        }

        protected override void Draw(GameTime gameTime) {
#if WINDOWS_APP
    // desktop related
#elif WINDOWS_PHONE_APP
    // phone related
#endif
            GraphicsDevice.Clear(Color.Magenta);
            base.Draw(gameTime);
        }
    }
}

在您的桌面项目

添加 SwapChainPanel

<Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <SwapChainPanel x:Name="SwapChainPanel1" />
    </Grid>
</Page>



运行游戏:

Run your game:

using Windows.UI.Xaml.Controls;

namespace App1 {
    /// <summary>
    ///     An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page {
        public MainPage() {
            InitializeComponent();
            Loaded += (sender, e) => {
                var myGame = new MyGame();
                myGame.Run(SwapChainPanel1);
            };
        }
    }
}

在您的手机项目

执行上面一样:

<Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <SwapChainPanel x:Name="SwapChainPanel1" />
    </Grid>
</Page>



最后:

And finally:

using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace App1 {
    public sealed partial class MainPage : Page {
        public MainPage() {
            InitializeComponent();

            NavigationCacheMode = NavigationCacheMode.Required;
        }

        protected override void OnNavigatedTo(NavigationEventArgs e) {
            var myGame = new MyGame();
            myGame.Run(SwapChainPanel1);
        }
    }
}



你做!

这篇关于是否有一个SharpDx模板,为Windows通用应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆