Game Development Reference
In-Depth Information
As you can see, I simply tied this conditional into the earlier example where I detect the win-
dow's resize event.
You may have also noticed from my snap view picture that I added some text telling the
player to click on the image in order to expand the game and exit snap view. This is very
easy to do. Simply add a click event to the image like this:
var snapView = document.getElementById("snap-view");
snapView.addEventListener('click', function(e) {
var boolean = Windows.UI.ViewManagement.ApplicationView.tryUnsnap();
})
As you can see, I have a simple image that fits perfectly in the 320-pixels-wide area provided
by the snap view and can also center it vertically in case the game is running at a higher res-
olution. Remember that the height of the snap view is determined by the maximum resolu-
tion of the attached monitor, so it can be larger than 786 pixels high.
The final thing we will want to make sure of is that whenever we enter snap view we pause
our game. Hopefully your game has a way to pause itself. We can simply listen to the same
resize event and determine if the game needs to be paused.
WARNING
It is critical that you also pause the game and any sounds or music playing to offer up a
clean experience when transitioning to snap view. If you are using a CSS-based solution,
make sure you don't forget to shut everything down in your game via JavaScript. The last
thing you want is for your game to be running in the background when the player can't in-
teract with it under the snap view image.
To play it safe, you should pause the game any time you detect a resize event. The simple act
of moving from snap to full or full to filled will probably be a little jarring for your players,
and they wouldn't have time to react on their own. Also, I wouldn't un-pause your game if
you leave snap view. You have to take into consideration that the player may have been do-
ing something else when the app was unsnapped, such as closing another app, and may not
be ready to jump back into the game. Whenever you change resolutions from full screen to
filled and down to snap view, you should pause the game and let the player manually resume
when they are ready.
Search WWH ::




Custom Search