如何将我的 Windows Phone 游戏移植到可以在网页上使用的 Silverlight 中?

发布于 2024-12-12 17:17:21 字数 545 浏览 0 评论 0原文

我对如何使用 Silverlight 将 WP7 C# 游戏移植到网络感到困惑。

我知道使用 Visual Studio 的 Windows Phone(插件?插件?其他?)用 C# 编写的代码可以生成 Silverlight 应用程序。但是如何将完成的 WP7 应用程序嵌入网页中呢?

我见过一些东西,例如 ExEnSilverSpriteXnaTouch {页面重定向到 MonoGame},但我很困惑是否需要这样的东西才能使我的游戏可以在网络上玩。我有一种感觉,该功能甚至可能嵌入到 Visual Studio 中。是否有可能在不重写所有代码的情况下做到这一点?

简短版本:如何使用 Silverlight 将我的 WP7 C# 游戏移植到网络上?

I'm confused about how to port my WP7 C# game to the web using Silverlight.

I know that code written in C# using the Windows Phone (add-in? plugin? other?) for Visual Studio makes a Silverlight app. But how can I embed my finished WP7 app in a webpage?

I've seen some things such as ExEn, SilverSprite, and XnaTouch {the page redirects to MonoGame}, but I'm confused if I even need something like this in order to make my game playable on the web. I've got a feeling the capability may even be embedded in Visual Studio. Is it even possible to do this without rewriting all the code?

Shortened version: How can I port my WP7 C# game to the web using Silverlight?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

深巷少女 2024-12-19 17:17:21

在 Visual Studio 中,在 WP7 项目旁边创建一个针对 Silverlight 的新项目。然后,如果您现有的代码结构良好,您应该能够重用大部分“后端”代码(人们谈论的视图、视图模型)。对于常见文件执行此操作的最佳方法是将它们添加为新项目的链接,因此您不必使它们都保持最新 - 如果版本之间存在微小更改,您可以使用条件编译来执行此操作这。

您将需要使用一些全新的类来处理某些事情,例如可能是顶级视图。某些 XAML(例如 UserControl 定义)可能可以在两者之间进行更改,但有些人会倾向于始终创建不同的版本。查看这篇关于跨平台 SL/WPF/WP7 开发的内容丰富的文章

Create a new project in Visual Studio targeting Silverlight beside your WP7 project. Then if your existing code is structured nicely, you should be able to re-use most of your "back-end" code (the views, viewmodels people talk of). The best way to do this for files that are common is to add them as links to the new project, so you don't have to keep them both up to date - if there are small changes between versions you can use conditional compilation to do this.

You'll want to use some completely new classes for some things, such as probably the top level view. Some XAML (eg a UserControl definition) might be usable between both with changes, though some people will favour always creating different versions. Have a look at this extensive article on cross-platform SL/WPF/WP7 development.

岁月打碎记忆 2024-12-19 17:17:21

你尝试了什么?

如果您在 Visual Studio 中创建 Silverlight 应用程序,您应该能够包含所有现有的视图、ViewModel、资源等。我不知道您是否能够创建一个同时构建到 WP7 和 Silverlight 应用程序中的项目,但我个人不会费心去尝试。

What have you tried?

If you create a Silverlight application in Visual Studio, you should be able to include all your existing Views, ViewModels, resources and so on. I don't know if you'll be able to make a single project that both builds into a WP7 and a Silverlight application but I personally wouldn't bother trying.

和我恋爱吧 2024-12-19 17:17:21

您不能直接这样做 - 缺少仅适用于 Windows Phone 应用程序的运行时组件和功能。

但是,您可以重用大量代码,尤其是 C# - 所有 XAML 代码,我相信,您必须从 WP7 XAML 复制/粘贴到 Silverlight XAML。

You can't directly - there are missing runtime components and features that are only available to Windows Phone applications.

You can, however, reuse lots of code, especially C# - all XAML code, I beleive, you'll have to copy/paste from WP7 XAML to Silverlight XAML.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文