Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guidance for structuring multiple scenes (like XNA Game State Management :)) #118

Closed
DanTup opened this issue Jul 20, 2015 · 4 comments
Closed

Comments

@DanTup
Copy link

DanTup commented Jul 20, 2015

I know Win2D isn't aimed purely at games, but it seems to be a reasonable use case (some of the members on CanvasAnimatedControl have Game in their names!). Something that isn't entirely clear to me at first glance is what the recommended way to break a game into multiple scenes (menus, levels, pause screen etc.) would be and how to navigate between them.

Eg:

  • Should there be 1 xaml file, and all switching between scenes is just done in code by rendering different things?
  • Should there be a xaml file for each "scene"? This might mean a lot of boilerplate XAML files of just a CanvasAnimatedControl, but might mean gaining some benefits from navigation structure already available there?
  • What are the "best" ways to transition between them (I believe XAML supports animations, would these make sense?)
  • Does content loading come into this? Can content be "unloaded"? (if not, then it seems a XAML file per scene is the only realistic option?)

XNA had a Game State Management sample which I thought was a great sample! It made it really easy to see how these things can hang together (and encouraged people to split these things up, rather than ending up with a monolithic game class). Having some similar guidance (whether it's a code sample, or just some paragraphs somewhere) for Win2D would be really useful.

Note: I did look at the sample gallery which uses separate XAML files; but there's some text on this page that suggests levels might be loaded within a single control.

@shawnhar A simple 2D game might make a great project for your next dog-fooding week ;O)

@damyanp
Copy link
Member

damyanp commented Jul 20, 2015

If you are planning to use Win2D for all of your drawing, then I would recommend using a single XAML file containing a CanvasAnimatedControl and arrange for different "scene" switching to be done there. I think that this would cover most game scenarios.

ExampleGallery is demonstrating many non-game scenarios with lots of interaction between XAML controls and CanvasControls. This is why it is structured as multiple XAML files.

Content can be unloaded simply by dropping all references to them. Most content can also be Disposed() as well to force the underlying GPU resources to be released. The app has full control over this.

@DanTup
Copy link
Author

DanTup commented Jul 23, 2015

Thanks!

Any advice around GC? Does it matter much on desktop? (With XNA on Xbox, much effort seemed to be spent avoiding allocations, forcing GC during loading screens, etc.)

@shawnhar
Copy link
Member

The CLR has improved a lot since its Xbox 360 incarnation. It's certainly possible to write code where GC will be perf issue, but this isn't usually a big deal.

@DanTup
Copy link
Author

DanTup commented Jul 23, 2015

Great; thanks for the info :)

Closing this, as I think there's enough info here to satisfy the request.. Hope you might consider a small 2D game for a future sample/app building week though!

@DanTup DanTup closed this as completed Jul 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants