63
Pur e Imaginat ion Extending Your Game with Windows 8 Features Frédéric Harper @fharper http://outofcomfortzone.net

Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

  • View
    2.021

  • Download
    3

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Pure

Imagination

Extending Your Game with Windows 8 FeaturesFrédéric Harper@fharperhttp://outofcomfortzone.net

Page 2: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Get Social at Pure Imagination

Chat about this session and ask questions on Twitter and Facebook.

w8pi.ca/PIonFB

@purelyimagineUse #Win8PI

Page 3: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

#GMG

#Win8PI4

Page 4: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

• Design for touch• Accelerometer• Snapped View• User Profile Data• Contracts• Live Tile• Monetize your apps

Agenda

Page 5: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Design for touch

Page 6: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Design for Touch FirstDesign with hands and fingers in mindHit targets should be sized and spaced for touch, your finger is not a pointerDesign with comfort, ergonomics and occlusion in mind

Page 7: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Design for Touch FirstDesign with hands and fingers in mind

Interaction areas Reading areas

Page 8: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features
Page 9: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Touch Platform Goals

Unify touch mouse and pen into a single pointer input AP

Express the touch interaction language in the platform

“Code for touch, get mouse and pen for free!”

Page 10: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

MSPointer

MSPointerDown, MSPointerUpMSPointerMoveMSPointerOver, MSPointerOut, MSPointerHoverMSPointerCancel

Basic DOM pointer events:

Derives from the same event class

Includes capture/bubble phase

Pointer events behave similarly to mouse events

Position (in the usual choice of coordinate systems)

Pointer type (touch, mouse, pen)

Contact id

Commonly used event properties:

Page 11: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Demo

Page 12: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Accelerometer

Page 13: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

The Accelerometer

accelerometer.addEventListener("readingchanged", function(evt){ // handle change});

Page 14: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

When the Application loads, we need to setup the accelerometer device. This is done in the app.onactivated event.

The report interval specifies in milliseconds how often the device will update the accelerometer data.

accelerometer = Windows.Devices.Sensors.Accelerometer.getDefault(); if (accelerometer !== null) { //accelerometer available on device // Establish the report interval var minimumReportInterval = accelerometer.minimumReportInterval; var reportInterval = minimumReportInterval > 16 ? minimumReportInterval : 16; accelerometer.reportInterval = reportInterval; }

Accelerometer Setup

Page 15: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Snapped View

Page 16: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Displaying Snapped View#snappedview { display:none;}

@media screen and (-ms-view-state: snapped) { #contentHost {/*hide main content*/ display:none; } #snappedview {/*show snapped view content*/ display:block; }}

Page 17: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

var viewStates = Windows.UI.ViewManagement.ApplicationViewState; var newViewState = Windows.UI.ViewManagement.ApplicationView.value; if (newViewState === viewStates.snapped) { ... //Application is in snapped view };

Custom Logic for Snapview

Page 18: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

User Profile data

Page 19: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

var userInformation = Windows.System.UserProfile.UserInformation;var userPic = userInformation.getAccountPicture();

var img = new Image();var imgurl = URL.createObjectURL(userPic);img.src = imgurl;

Getting User Profile Data

Page 20: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Demo

Page 21: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Contact contract

Page 22: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

The contact picker launches a UI that will return a single contact.

Using ContactPicker

Page 23: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

// get reference to ContactPickervar picker = Windows.ApplicationModel.Contacts.ContactPicker();

// open the pickerpicker.pickSingleContactAsync().then(function (contact) {

// handle contact information});

Handle the result

Page 24: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

contact.getThumbnailAsync().done(function (thumbnail) { // generate a URL for the thumbnail image thumbURL = URL.createObjectURL(thumbnail);

// use thumbURL to update the src of an image for // display face_img.src = thumbURL;});

Getting contact thumbnails

Page 25: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Demo

Page 26: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Share

Page 27: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

People love to share

Page 28: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Share provides a lightweight,

in context experience for

app to app sharing

Page 29: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

From source to target

Page 30: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Demo

Page 31: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Data package Plain text Formatted text URI HTML Images Files Custom data formats

Page 32: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Share sourcedataTransferManager.addEventListener("datarequested", function (e) {…// Common propertiesvar request = e.request;request.data.properties.title = "Title for data"; request.data.properties.description = "Description of the data"; request.data.properties.thumbnail = thumbnail; // of type StreamReference

// Common methods request.data.setText("Text to share");request.data.setHtml("<HTML …>");request.data.setUri(uri /* of type Uri */);request.data.setBitmap(stream /* RandomAccessStream */);

// Custom data request.data.setText("FormatID", "Text to share");request.data.setData("FormatID", datastream /* RandomAccessStream */);

Page 33: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Share source example// set up data transfer managervar dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();

// create event listener to be called on to fill out data packagedataTransferManager.addEventListener("datarequested", function (e) {// fill in data package with what to sharevar request = e.request;request.data.properties.title = "Title for data"; request.data.properties.description = "Description of the data"; request.data.setText("Text to share");...});

Page 34: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Share target example<!– extension needs to be added to package.appxmanifest --><Extensions>

<Extension Category="windows.shareTarget" StartPage="shareTarget.html">

<ShareTarget><SupportedFileTypes><FileType>.jpg</FileType>

</SupportedFileTypes><DataFormat>text</DataFormat>

</ShareTarget></Extension>

</Extensions>...// activation function in shareTarget.jsfunction activated(e) {

if (e.kind === Windows.ApplicationModel.Activation.ActivationKind.shareTarget) {

share = e.shareOperation;document.querySelector('.metadata h1').textContent = share.data.properties.title;document.querySelector('.metadata p').textContent = share.data.properties.description;

Page 35: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Demo

Page 36: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Settings

Page 37: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Settings contractprovides quick,

consistent, in-context access

to settings in your app

Page 38: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Add a settings page function scenario2AddSettingsFlyout() { WinJS.Application.onsettings = function (e) { e.detail.applicationcommands = { "helpDiv": { title: "Help",

href: "/html/2-SettingsFlyout-Help.html" } }; WinJS.UI.SettingsFlyout.populateSettings(e); };}

Page 39: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Demo

Page 40: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Live tile

Page 41: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Demo

Page 42: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

var notifications = Windows.UI.Notifications;var template = notifications.TileTemplateType.tileWideSmallImageAndText02;var tileXml = notifications.TileUpdateManager.getTemplateContent(template);

var line1 = tileXml.getElementsByTagName("text")[0];

line1.appendChild(tileXml.createTextNode(“Yeti Stats"));

Live Tile

Page 43: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

var tileNotification = new notifications.TileNotification(tileXml);

notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification);

Creating a Notification

Page 44: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Demo

Page 45: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Monetize your game

Page 46: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Flexible monetization models

Existing relationship

Subscriptions

Consumable purchases

Use Your Existing Commerce

Use our ad system

Bring your own

Ad Supported

Time limited trials

Feature differentiated trials

One time Purchase

Persistent purchases

Expiring purchases

Purchases over time

Page 48: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Trials in Windows 8

Time limited Feature differentiated

Page 49: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Time-based trials

/* No code*/

Page 50: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Trial conversion(JS)// get current productvar currentProduct = Windows.ApplicationModel.Store.CurrentProduct;

// get the license informationvar licenseInformation = currentProduct.licenseInformation;// check to see if the user has an active non-trial license

if (licenseInformation.isTrial) { // user has trial version of the application // prompt them to purchase before so we can enable full functionality

currentProduct.requestAppPurchaseAsync().then( function () { // Purchase succeeded

EnableFullFunctionality(); });

}

Page 51: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Download the Microsoft Ad SDK:http://advertising.microsoft.com/windowsadvertising/developer

<div id="ad_bottom_rail“ data-win-control="MicrosoftNSJS.Advertising.AdControl"

data-win-options="{applicationId: 'd25517cb-12d4-4699-8bdc-52040c712cab',

adUnitId: '10043074'}"></div>

<script src="/MSAdvertisingJS/ads/ad.js"></script>

Implementing Ads using the MS

SDK

Page 52: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

In-App Purhase(JS)// can’t do in-app purchase in trial mode, must convert first if (!appLicensingInformation.isTrial) { //load the listings with all the products currentApp.loadListingInformationAsync().then( function (listing) {

//lookup a specific product var product1 = listing.productListings.lookup("product1"); if (!product1.isActive) {

// purchase currentApp.requestProductPurchaseAsync("product1“, false ).then(

enableProduct1 ); }

});

Page 53: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Where to go from here

Page 54: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Combo System: Keep track of Hikers hit by each Snowball and reward the player for massive combos

Power-ups:Add other objects on the map to hit that make your Yeti stronger

Different Hikers:Hikers that have different paths or take multiple hits

Different Levels:Adding in different mountains for the Yeti to defend.

Game Features

Page 55: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Share Screenshots of the game with the Share Charm.

Customize the style of the App Bar.

In-App Purchases

Cropping and editing of profile, and contact images.

Extend the Settings charm.

Windows Features

Page 56: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features
Page 57: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Get notified about upcoming CreateJS

Workshops in Canada!

aka.ms/createjsworkshops

CreateJS.com

Page 58: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Ressources

Windows Dev Center http://dev.windows.com

Build New Games: http://buildnewgames.com/

From zero to hero! Building a Windows Store game in HTML5 http://channel9.msdn.com/Events/Build/2012/3-110

Developing, deploying, and monetizing Windows Store games with Unity http://channel9.msdn.com/Events/Build/2012/3-135

Page 59: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Doing a Windows 8 game?

Page 60: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Ping me [email protected]

Page 61: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Microsoft is committed to protecting your privacy. Survey responses are collected by Poll Everywhere, a market research company commissioned by Microsoft to conduct this survey.

• This survey does not request or collect any additional personal information from you nor does this survey use any cookies or other technologies to track your responses to the survey.

• Your responses to this survey will not be linked to the contact information previously collected by Microsoft. Your answers will be reported in aggregate with those of other respondents.

• This privacy statement applies only to the survey for this event or session. It does not apply to other online or offline Microsoft sites, surveys, products, or services.

Session Evaluation

Page 62: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Submit your session eval at

Your feedback matters. We listen to your comments and feedback in order to continue to improve these types of sessions.

Session Eval

w8pi.ca/gmg4eval

Page 63: Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 Features

Questions

Frédéric Harper

[email protected]@fharper

http://webnotwar.cahttp://outofcomfortzone.net