简体   繁体   English

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

[英]How can I port my Windows Phone game to a Silverlight thing that I can use on a webpage?

I'm confused about how to port my WP7 C# game to the web using Silverlight. 我对如何使用Silverlight将WP7 C#游戏移植到Web感到困惑。

I know that code written in C# using the Windows Phone (add-in? plugin? other?) for Visual Studio makes a Silverlight app. 我知道使用Visual Studio的Windows Phone(加载项?插件?其他?)用C#编写的代码构成了Silverlight应用程序。 But how can I embed my finished WP7 app in a webpage? 但是,如何将完成的WP7应用程序嵌入网页中?

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. 我已经看到了一些东西,如内胚SilverSpriteXnaTouch {页面重定向到MonoGame},但我很困惑,如果我甚至为了让我的游戏在网络上播放的需要是这样的。 I've got a feeling the capability may even be embedded in Visual Studio. 我感觉该功能甚至可以嵌入到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? 简化版:如何使用Silverlight将WP7 C#游戏移植到Web上?

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. 如果在Visual Studio中创建Silverlight应用程序,则应该能够包含所有现有的Views,ViewModels,资源等。 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. 我不知道您是否能够制作一个既可以构建到WP7又可以构建到Silverlight应用程序中的项目,但是我个人不会尝试。

You can't directly - there are missing runtime components and features that are only available to Windows Phone applications. 您不能直接-缺少仅适用于Windows Phone应用程序的运行时组件和功能。

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. 但是,您可以重用许多代码,尤其是C#-我相信所有XAML代码都必须从WP7 XAML复制/粘贴到Silverlight XAML。

Create a new project in Visual Studio targeting Silverlight beside your WP7 project. 在WP7项目旁边的Visual Studio中创建一个针对Silverlight的新项目。 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. 某些XAML(例如UserControl定义)可能在两个更改之间都可以使用,尽管有些人会倾向于始终创建不同的版本。 Have a look at this extensive article on cross-platform SL/WPF/WP7 development . 看一下有关跨平台SL / WPF / WP7开发的大量文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以将Windows Phone用作unity3d游戏的遥控器吗? - Can I use my Windows Phone as remote for my unity3d game? 如何使用Windows Phone和Selenium? - How I can use Windows Phone and Selenium? 在Silverlight Windows Phone 7应用程序中,我可以使用什么代替System.Web.Services.Description? - what can i use instead of System.Web.Services.Description in Silverlight Windows Phone 7 app? 如何在.aspx网页上使用默认的siteLayout? - How can I use my default siteLayout with my .aspx webpage? 如何在Windows Phone 8.1 Silverlight应用程序中创建PDF Viewer - How can i create PDF Viewer in Windows Phone 8.1 Silverlight Application 如何使用WCF调用从客户端Windows Phone 8.0 Silverlight返回对象的方法 - How can I call a method that returns an object from a client windows phone 8.0 silverlight using WCF 如何在SilverLight或Windows Phone中为布局(某些元素)创建事件 - How can I make an event for the Layout (exept some elements) in SilverLight or Windows Phone 如何测量Windows Phone上拖动的时间? - How can I measure the time of a drag on my Windows Phone? 如何在Windows Phone 8上重置文本框值 - How can I reset my textbox value on Windows Phone 8 如何检查Windows Phone设备的当前方向? - How can I check the current orientation of my windows phone device?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM