60
Pur e Imaginat ion Getting Your HTML5 Game Windows 8 Ready with WinJS Frédéric Harper @fharper http://outofcomfortzone.net

Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

  • View
    1.709

  • Download
    0

Embed Size (px)

DESCRIPTION

You already created an HTML5 game, and you want to make it a Windows 8 game to get all the benefits of this new platform? The recipe is simple: take your HTML5 games, add some WinJS dressing, use Visual Studio to make these stick together, and get in the Windows Store oven to get a perfectly cooked app!

Citation preview

Page 1: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Pure

Imagination

Getting Your HTML5 Game Windows 8 Ready with WinJSFrédéric Harper@fharperhttp://outofcomfortzone.net

Page 2: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

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-24 - Getting your HTML5 game Windows 8 ready with WinJS

#GMG

#Win8PI2

Page 4: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

• Windows 8• WinJS• Application Structure• Navigation• Data Binding• App Bar Integration

Agenda

Page 5: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Windows 8

Page 6: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Windows reimaginedA new Windows UI where touch is a first-class citizen along with full mouse-and-keyboard support

New development models built on WinRT, including native support for HTML/CSS/JS, C#/XAML, C++/DirectX

Designed from the chipset up for multiple form-factors – tablets, laptops, desktops & all-in-ones

The Windows Store on every device with a full commerce platform and flexibility

Page 7: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Paid downloads, trials, and in-app purchases. You keep 70% of the first $25k, 80% of the rest

Microsoft Confidential 7

Robust analytics for free, including demographics, reviews, referrals, and usage & performance statistics

Use your own commerce engine and keep 100%or use the Windows Store’s full commerce platform

The Windows Store

Advertise with Microsoft Advertising or your preferred ad vendor.

Page 8: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Opportunity

As of March 2012, IDC

690M

Windows 7

345M

Android

196M

iOS

32M

Mac

Page 9: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Unprecedented Reach

100+languages

Store & Apps in:

200+markets

Buy from:

70+ markets ( including top 40 by GDP)

Local pricing & settlement:

Page 10: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Tools

Page 11: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Windows 8

Windows Core OS Services

JavaScript(Chakra)

CC++

C#VB

Windows 8 Store Apps

Communication

& Data

Application Model

Devices & Printing

WinRT APIsGraphics &

Media

XAML HTML / CSS

HTMLJavaScri

ptCSS

CC++

C#VB

Desktop Apps

Win32

.NET / SL

Internet Explore

r

Syst

em

Serv

ices

Vie

wM

od

el

Contr

olle

rC

ore Windows Core OS Services

Communication

& Data

Application Model

Devices & Printing

Graphics & Media

Syst

em

Serv

ices

Core

Page 12: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

All the good the stuffCSS 2D Transforms

CSS 3D Transforms

CSS Animations

CSS Backgrounds & Borders

CSS Color

CSS Flexbox

CSS Fonts

CSS Grid

CSS Hyphenation

CSS Image Values (Gradients)

CSS Media Queries

CSS multi-column Layout

CSS Namespaces

CSS OM Views

CSS Positioned Floats (Exclusions)

CSS Selectors

CSS Transitions

CSS Values and Units

Data URI

DOM Element Traversal

DOM HTML

DOM Level 3 Core

DOM Level 3 Events

DOM Style

DOM Traversal and Range

DOMParser and XMLSerializer

ECMAScript 5

File Reader API

File Saving

FormData

HTML5 Application Cache

HTML5 async

HTML5 BlobBuilder

HTML5 Canvas

HTML5 Drag and drop

HTML5 Forms and Validation

HTML5 Geolocation

HTML5 History API

HTML5 Parser

HTML5 Sandbox

HTML5 Selection

HTML5 semantic elements

HTML5 track

HTML5 video and audio

JavaScript Typed Array

ICC Color Profiles

IndexedDB

Page Visibility

Pointer (Mouse, Pen, and Touch) Events

RequestAnimationFrame

Navigation Timing

Selectors API Level 2

SVG Filter Effects

SVG, standalone and in HTML

Web Messaging

Web Sockets

Web Workers

XHTML/XML

XMLHttpRequest (Level 2)

XMLHttpRequest CORS

Page 13: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Windows Library for JavaScript (WinJS)library for building apps using JavaScript

Web technologies you’re already familiar with

Utilities and patterns for responsive, reliable apps

Use interactive design tools

Build your apps fast and with high quality

Matches the Windows 8 design style

Controls for common user experiences

Designed for touch as well as traditional input

Scales across form factors

Make your apps look and feel great

Page 14: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

WinJSHelpers for Namespaces, Constructor Definition

Promises

App Model

Navigation

Page & User controls

Data binding

Controls

Animations

Templates

Utilities

Default CSS Styles

Page 15: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Everyday widgetsButton

Checkbox

Combo Box

Date PickerRadio Button

Hyperlink

ListBox

Ratings

Progress Bar

Progress Ring

Time Picker

Toggle Switch

Slider

Page 16: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Windows 8 Animation LibraryContains key Windows Store app animationsHas the same storyboard values, curves, and even the same API that Windows uses

Aligns your app to the Windows 8 personality

Page 17: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Animation Library Scenarios

Content enterContent/exitContent Expand/collapse Peek

Reveal/Hide UI showEdgeUI/hideEdgeUI showPanel/hidePanelshowPopup/hidePopup

NavigationenterPage/exitPage

SelectionPointer animationsSwipe select/swipe deselectSwipe reveal

CollectionsAddItemToList Delete item from list

Page 18: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Demo

Page 19: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Prefer your own library? Go ahead! Adhere to the Windows UI and personality

Understand our web context & sandboxing model

Mix & match works fine

Page 20: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Design for Multiple Views

Widescreen (1366x768+) Snap view (required)Minimum (1024x768)

Portrait

People multi-task. An application can be displayed any one of these layouts:

Page 21: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Scaling

Watch BUILD talk APP-207T/847T Reach your customers’ devices with one beautiful HTML5/XAML user interface

PCs will have a wide range of screen sizes and resolution

Use fluid layout (e.g. -ms-grid control, ListView control) to take advantage of screen real estateScale to fit (e.g. viewbox control) for fixed layoutsUse the VS simulator to see how your app will look on different machinesSystem-provides automatic scaling based on resolutionUse scalable vector graphics, or Provide 3 sizes of assets (100%, 140%, 180%) and use resource loading for bitmap format images

Page 22: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Screen sizes

10” 1024x76813” 1400x105020” 1920x108030” 2560x160011.6” 1366x768

Page 23: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Screen sizes

The minimum app resolution is 1024x768 A good place to start designing your app is 1366x768Apps take advantage of added screen real-estateShow more contentManage white spaceUse the VS simulator to see how your app will look on different machines

Page 24: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

HTML5 game demo

Page 25: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Page structure

Page 26: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Page Structure

Page 27: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Navigation Project Template

Page 28: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Porting your HTML5 Game

Page 29: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Adding Pages

Page 30: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS
Page 31: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

WinJS

Page 32: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

WinJS.Utilities.query("a").listen("click", function (evt) { // dont load this link in the main window evt.preventDefault();

// get target element var link = evt.target;

//call navigate and pass the href of the link WinJS.Navigation.navigate(link.href); });

Overriding Link Behavior

Page 33: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

WinJS.UI.Pages.define("/home.html", { // This function is called whenever a user navigates to this page.

ready: function (element, options) { //run code unique to this page }

});

WinJS.UI.Pages.define

Page 34: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Demo

Page 35: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Data binding

Page 36: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Data Binding with WinJS.Binding.List

var hikerArray = [{ title: 'John Smith', color:'#333333', body_img:'/images/body_333333.png', face_img:'/images/default_face.png', }, { title: 'Erin Dodge', color:'#00c0ac', body_img: '/images/body_00c0ac.png', face_img:'/images/default_face.png', }, { title: 'James Parker', … } ];

var hikerBindingList = new WinJS.Binding.List(hikerArr);

Data Binding with WinJS.Binding.List

Page 37: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

var publicMembers = { itemList: hikerBindingList };

WinJS.Namespace.define("DataHikers", publicMembers);

WinJS.Namespace.define

Page 38: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

WinJS.UI.ListView

Page 39: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

<div id="hikerListView" data-win- control="WinJS.UI.ListView" data-win-options="{ itemDataSource: DataHikers.itemList.dataSource, itemTemplate: select(‘#hikersTemplate’) }“></div>

WinJS.UI.ListView

Page 40: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

<div id="hikersTemplate" data-win-control="WinJS.Binding.Template"> <div class=“template_item"> <div class=“img_wrap"> <img class="face" data-win-bind="src: face_img" /> <img class="body" data-win-bind="src: body_img" /> </div> <div class=“overlay"> <div class=“text" data-win-bind="innerText: title"></div> </div> </div></div>

Define the Template

Page 41: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

WinJS.UI.processAll();

Define the Template

Page 42: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Styling the Template

Page 43: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

App Bar

Page 44: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS
Page 45: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS
Page 46: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Content Before Chrome

Content comes first. Immerse users in the things they loveLeave only the most relevant elements on screen to minimize distractions

Traditionally chrome is added for:1. Layout2. Interactions3. Navigation

Page 47: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Demo

Page 48: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

<div id=“hikersAppBar" data-win-control="WinJS.UI.AppBar"></div>

WinJS.UI.AppBar

Page 49: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

<div id=“hikersAppBar" data-win-control="WinJS.UI.AppBar"> <button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmdAdd', label: 'New Hiker', icon: 'add'}"></button></div>

Adding Commands to the AppBar

Page 50: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

<div id=“hikersAppBar" data-win-control="WinJS.UI.AppBar"> <button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmdAdd', label: 'New Hiker', icon: 'add'}"></button></div>

Command Options

Page 51: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

// get add command elementvar cmdAdd = document.getElementById('cmdAdd');

cmdAdd.addEventListener('click', function (ev) { // respond to add hiker command});

Adding Functionality

Page 52: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Demo

Page 53: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS
Page 54: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Get notified about upcoming CreateJS

Workshops in Canada!

aka.ms/createjsworkshops

CreateJS.com

Page 55: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

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 56: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Doing a Windows 8 game?

Page 57: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Ping me [email protected]

Page 58: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

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 59: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

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/gmg2eval

Page 60: Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 ready with WinJS

Questions

Frédéric Harper

[email protected]@fharper

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