问题
I am trying to build an simple game using XNA 4.0 on Windows Phone.
On my project, I will have 2 page, MenuScreen
and GameplayScreen
. In Silverlight, I can add new page easily And I can use NavigationService.Navigate("/blablabla.xaml")
to move to another page on my project.
How can I do that on XNA? There are no page options when I want to add new item.
回答1:
Because XNA hasn't the concept of page. If you need to use Silverlight you can easily create a project that use XNA and Silverlight, merging their features.
Otherwise, if you can't use Silverlight in your project, you have to implement your MenuScreen
class that will manage what you need (buttons and detecting touches) and then, when you want to launch the GameplayScreen
, you simply call your class that manage your game (like a sprite manager or a model manager), hiding the menu class or deactivating it.
Of course every class has to inherit from DrawableGameComponent
.
来源:https://stackoverflow.com/questions/18544522/game-page-navigation