Cut the Rope in HTML5 is live

Its alive! Cut the Rope is now available in HTML5 on the web at www.cuttherope.ie

I was fortunate enough to be a part of this project and am pleased to see it up and running. Hats off to ZeptoLab for creating a great game with such a fun visual style.  And much praise to the two masters Joel Fillmore (JS Game Engine Lead) and Robby Ingebretsen (Project/Visuals/Everything Lead).

For more information on the developer story, checkout the Behind the Scenes site and grab some developer candy while you’re there.

Om nom, nom, nom.

Posted in Client Technologies | Tagged , , , | Leave a comment

Setting up your first use of the Animation library in WinJS

The WinJS Animation library provides some pre-scripted animation functions that allow you to easily reproduce the signature animations of Metro-style apps.  Since there is no “Animated Application” template (and I don’t think there should be).  I thought I’d share the first couple of steps needed to use the library in your own application.

1. Create a new JavaScript (Blank Application) Project in VS11 Express.

2. In default.html, add an element to be animated.  I chose a header taking advantage of the provided classes of the theme CSS.

<h1 class="pageTitle win-title">First Animation</h1>

3. Next add a reference to the Animation library which is defined in the “animations.js” file under the ”winjs/js” folder.  Additionally if you open this file, you will find in the comments at the top that this library is dependent on the “base.js” file and the “ui.js” file.  The first file is already referenced but “ui.js” needs to be added.  Add the references to your default.html file, like the following:

<script src="/winjs/js/base.js"></script>
<script src="/winjs/js/ui.js"></script>
<script src="/winjs/js/animations.js"></script>
<script src="/winjs/js/wwaapp.js"></script>

4. Switch over to default.js, and in the onmainwindowactivated method add the following code to locate the element and run the page enter animation.

var pageTitle = document.querySelector('.pageTitle');
WinJS.UI.Animation.enterPage(pageTitle);

Its important to notice the namespace is “Animation” and “Animations”.  One reason I was prompted to write this post is because the Windows 8 dev center example code erroneously uses “Animations”. Certinaly frustrating when you’re just getting started.

Run. Run the example and you should see after the app starts up, the page title slides into view with a short animation.

What about chaining a second animation after this first animation? Since animation functions return promises its very to do so.  Check it out.

5. Add another element below your first in default.html. Let’s use the fadeIn function this time, so set the opacity to “0″.

<h1 class="pageTitle win-title">First Animation</h1>
<p style="opacity:0">My hidden content</p>

6. Now go back to default.js and add a then call on enterPage. Inside define a function that locates the second element and calls fadeIn.

var pageTitle = document.querySelector('.pageTitle');
WinJS.UI.Animation.enterPage(pageTitle).then(
    function() {
        var p = document.querySelector('p');
        WinJS.UI.Animation.fadeIn(p);
    }
);

Run.  Now when you run the app, after the page title slides in, the paragraph below should fade in to view.

And that’s it to getting started! If you look at the WinJS.UI.Animation namespace you’ll find the other available scripted animations.

Looking through the “animations.js” file, I found it interesting to not that the available functions actually make a call to the Win.UI.executeTransition function, so if you’re looking to run some custom animations you can do that too.

I’m sure I’ll be posting more about the Animations library soon.  I’m not sure what everything does yet, but it sure is fun to poke around.

Posted in Client Technologies, Tutorials | Tagged , , , | 2 Comments

No Alert in WinJS! Use console or MessageDialog instead

Please excuse the superfluous exclamation point in the title, this is not a true emergency.

Most JavaScript developers have moved on from debugging with the alert function, but sometimes the quick and very dirty function comes up as an old instinct. This instinct will be squashed if you attempt to use alert or its siblings, confirm or prompt, when beginning your Windows 8/WinJS education.  A call to one of these functions will cause the Visual Studio debugger to break and throw an undefined exception.

Thankfully there is a JavaScript console available in Visual Studio so you can simply call console.log(). The following steps will take you that far:

1. Create a new JavaScript (Blank Application) Project in VS11 Express.

2. Add an element to your default.html page providing something to click on. You could go with boring old text, but I went for a leaf image (pictured above, download) and i gave it an ID of “leafImage”.

3. Next add an event handler in the onmainwindowactivated function in default.js. You can remove the ActivationKind check as it doesn’t matter for this sample.  Now when adding the eventHandler I skipped over ‘click’ and instead attached to ‘MSPointerDown’ fully embracing the new Input system of Windows 8:

leafImage.addEventListener('MSPointerDown', function(){
    //alert('leaf pointerdowned');
    console.log('leaf pointerdowned');
});

Run. Now if you run this code, you will see your text or image and once you click it with a mouse or tap it with your finger the event will fire. Alt-tabbing over to VS you should see the text logged in your JavaScript Console.

This does mean you need to alt-tab to see the information, but what about showing the info in the app?  You could use the other method of a debug div element sitting in your HTML that you can write to.  That still works perfectly fine.

Another option available is the MessageDialog, especially if this info is not just debug info but rather some information you want to share with user.  Possibly even allowing the user to make a choice or give their opinion. To use the Message Dialog you can use the following code:

leafImage.addEventListener('MSPointerDown', function(){
    //alert('leaf pointerdowned');
    console.log('leaf pointerdowned');

    var md = new Windows.UI.Popups.MessageDialog('Ready for Monday?');
    var result, resultOptions = ['Oh yeah!', 'Nooooo!'];
    var cmd;

    for(var i = 0; i < resultOptions.length; i++) {
        cmd = new Windows.UI.Popups.UICommand();
        cmd.label = resultOptions[i];
        cmd.invoked = function(c) {
            result = c.label;
        }
        md.commands.append(cmd);
    }

    md.showAsync().then(function (c) {
        console.log('answer: ' + result);
    });
});

And now let’s break it down.

4. (Line 5) Notice the MessageDialog is from the Windows namespace and not WinJS. This is an example of the native WinRT-integrated-frameworks-in-action.

5. (Line 10-15) a UICommand is added for each child of the resultOptions array.  Adding the label in invoked handler can also be set in the constructor.

6. (Line 18) Notice the use of the promise object with the then function.  This is how asynchronous methods are handled in WinJS, which is already an existing popular JS pattern in libraries like jQuery for example.

7. (Line 19) For some reason the event arg c is always equal to the last UICommand added to the collection, resulting in the need for the separate result variable.  Based on the documentation I’m not sure if this is an error, but it seems like it should return the selected UICommand instead.

Run. Running the app and clicking the image I found two different results. The left image is run from VS and shows the MessageDialog with a black background.  The right image is the app run in Interactive Mode in Blend showing the MessageDialog with a green (and I believe the correct) background.

Additionally while running the app in Blend I noticed that there was no JavaScript console there.  Let’s hope one is added before Blend 5 ships, as that will make debugging across the tools simpler.

Overall it is just a “Developer Preview”, but so far exploring Windows 8 has been a lot of fun. Expect more posts in the future.  This stuff is not well documented and I’m happy to share and get feedback on how things currently work.

Posted in Client Technologies, Tutorials | Tagged , , , | 2 Comments

Thinking of Pinned Apps conceptually on Windows Phone

One of the more distinctive features of Windows Phone is the Start screen – which includes nice big live tiles that you can add and organize however you prefer. Up until the latest release, pinned items have been limited to applications, contacts, websites and other native or system level items.

With the latest release, a new feature has been added for app developers called Secondary Tiles. The new tiles allow users to create shortcuts on the Start screen to a deep location (at least one-level beyond the homepage) of an application.

This is a big win for app users as it allows them quick access to something they really care about. And it is a big win for developers, as a unique feature of Windows Phone and as a way for their app to become even more valuable and loved by the user.

So how do you design your app with this feature in mind?

This is a design challenge I recently worked through and not finding much documentation on the topic, I’ve decided to share my thoughts.

Quick Tiles Overview

Before there were secondary tiles, there was the primary tile, formally known as the Application Tile.  The job of this tile is simple – open the application to the home page, defined by the default task in your WMAppManifest.xml file.  Even though they may not currently be pinned to the Start screen, they always exist and are accessible as the first entry in the ShellTile.ActiveTiles collection.

Secondary Tiles are created via code in response to user interaction (e.g. click of a “Pin to Start” button).  When created the tiles are given a unique NavigationUri, reflecting the purpose of the tile to link to a specific place or thing within the application.

Both types of tiles have six properties – Title, BackgroundImage, Count, BackTitle, BackBackgroundImage, BackContent.  The first three should be obvious in functionality.

The second three properties once set will cause the tile to flip, as though you were looking at two sides of the tile in space.  This is a great way to get the user’s attention, but could be abused by over usage.  For an avant-garde usage of flipping tiles check out Flipping Tiles.

For more information, check out the Tiles Overview on MSDN.

Just a Slice of the App

Now that we have the basics on the table, what does this mean for design?

Think of a Pinned App as a manifestation of the “Be ‘On the Go’ Capable” Metro Principle. By pinning a specific single unit (location, person, book, etc) to the Start screen, the user has less typing, less navigation and any other type of data entry to make it to their favorite or valuable object.

Since the intention is to focus on the single object, this gives you a license to only expose the object and the segment of the app that deals with the object.  Let’s take a look at a real example to explain the idea and see it in action.

The People Hub is used to expose all of your contacts information and statuses.  Its an easy way to get the most recent statuses or search for a contact in order to get in touch with them.  I can select a specific contact, check out their info and hit Back to return to the People Hub.

Now, I have this friend named Pinto Snows who like I to keep in close touch with. I can pin him to my Start screen, so I have quick access to his contact info and status by selecting him via his very own tile.  If I close the app, I return to the Start screen and not the People Hub.  For one thing, I came from the Start screen so that’s where I expect to return.  Secondly, I only wanted info about him, I don’t need to look up anyone else.

This is a very “on the go” interaction.

There is no need to go to the homepage of the app from here, this is just a slice of the app.

Development and Implementation

When developing the app, this “slicing” needs to be taken into consideration.

The page that loads from a Secondary Tile must be self-sufficient. It can’t depend on data being loaded from the home page or some other page. There are two simple ways to detect whether a page has been opened via a Secondary Tile:

  1. NavigationContext.QueryString – the Uri for secondary tiles should be unique and ideally pass an ID in the QueryString. Depending on how you have developed an app, this may be enough to detect the difference.  If you are already using QueryStrings to pass information, just use a unique parameter when setting the Uri for the SecondaryTile, such as “pinned=true”.

  2. NavigationService.CanGoBack – since the page is normally loaded by navigating within your app, this property will be true.  In a pinned situation where this page is loaded as the first page, the property will be false.

The biggest difference here is that when the user hits the Back button they are leaving your app, unlike a non-pinned situation where they go up one-level or to the homepage.  The good news is you have the previously mentioned ways to detect the situation as well as the normal application-level events to save state and data if needed.

For a good example of a third party application following this pattern, check out 4th and Mayor pictured to the right.  The first image shows the app and a specific location (below Settings) pinned to Start. The second image shows the location opened via the pinned tile.

One more suggestion (which is done in People, not in 4th and Mayor) is to disable the Pin button if the user has already pinned that object to Start.  You can easily check for the existence of the pinned tile be querying the ShellTile.ActiveTiles collection and comparing NavigationUri values.

Posted in Client Technologies, Design Thinking | Tagged , , , , | Leave a comment

Talking about HTML5 on Yet Another Podcast

Jesse Liberty was kind enough to invite me back on to his cleverly named podcast, Yet Another Podcast, to talk about the technology of been focused on lately, HTML5.

In YAP episode #48, we talk about the type of work I do as a UI/Interactive/Visual Design Developer and the sometimes large or small degrees between the design and development teams. After that we dive into thoughts on building HTML5 apps, mainly focused on data visualizations and games.

Posted in Client Technologies | Tagged , , , | Leave a comment

New Windows Phone “How Do I” Video Series

Working on a few WP7 videos

“How do I…do something new in and cool in Windows Phone ‘Mango’? This is Adam Kinney for Microsoft and today we’re going to answer that question by…”

If you are new to Windows Phone 7 Development or you want to get a look at on e of the new features in action check out the new Windows Phone “How Do I” Video Series

Each 10-15 minute video focuses on a single topic and walks through an example of code. I had a lot of fun putting these together and I think the “Mango” update will be huge for Windows Phone 7 developers and users. They’ve thrown in some really nice new features in there like deep linking tiles, flipping notification tiles, sockets, local database and more OS integration with new tasks and access to contacts and appointments data.

Here’s the full list of videos:

Posted in Client Technologies, Tutorials | Tagged , , , , , | 4 Comments

I’m doing the BUILD HIVE 2011 conference combo


I’ve been looking forward to the BUILD conference since it was announced.  Seeing the Windows 8 demo, with its fancy new Metro evolved look and the fact that new development technologies are on the horizon, makes me feel giddy at the idea of once again a new technology to explore, hate and love.

I had all my plans in place and everything was set until Friday night I caught wind of the HIVE conference happening right here in the Seattle area.

A design and tech conference happening right here, with all the cool kids in the neighborhood?  How could I miss it?

Well, I almost could have because it happens to be on September 16th the last day of the BUILD conference.  Hmm, the last day of a 4-day conference, that’s where the conference organizers tend to place the sessions that they should run, but are not the most excited about.  I bet if I catch those online later, I won’t miss too much.

So the decision is made. Fly down to Anaheim for BUILD, soak up Windows 8 and HTML5 goodness then come home a day early to attend HIVE and ruminate over design and developer workflow and be inspired to do greater work.

Anyone else doing the BUILD HIVE combo?

Posted in Client Technologies, Storytelling | Tagged , , , , | 4 Comments

Check if your WP7 app is a Bing Instant Answer

After reading through all of the Windows Phone 7 “Mango” documentation, this is one tip that stuck out as a simple but nice feature that I haven’t seen mentioned much.

Search on Windows Phone 7 “Mango” has been upgraded to include the concept of an App Instant Answer.

For example, you search for “xbox” and right inline with the results, in the prime top spot, is a link to Bing’s top WP7 app result for that search term.

From there you can tap the thumbnail to download or launch the app.

This new feature and the addition of quick cards is a nice example of how the WP7 team is focusing on improving the flow of using a mobile device. +1 for the deep integration between Bing and Windows Phone.

Now the nice thing is that when the app is launched, a parameter is passed via query string so that you can discover and track when your app has been opened using App Instant Answer.

You can easily grab the search term by using this code:

if(this.NavigationContext.QueryString.ContainsKey("bing_query"))
{
      string searchTerm = this.NavigationContext.QueryString["bing_query"];
      //do something awesome with searchTerm
}

And you can debug your app in Visual Studio by updating the task in the WPAppManifest.xml file:

<DefaultTask  Name ="_default" NavigationPage="MainPage.xaml?bing_query=xbox"/>

For a full tutorial on this topic see How to: Integrate with App Instant Answer for Windows Phone

Posted in Client Technologies | Tagged , , | 2 Comments

Building a Windows Phone 7 game at the Kinect Code Camp

This week I had the unique opportunity to take part in the Kinect Code Camp, a quiet event starting 24 hours before the public launch of the Kinect SDK.

From the beginning there was a great vibe going on provided by the Channel 9 and Coding 4 Fun folks. Everyone was excited about the possibilities of Kinect and we were all ready to see what we could build in 24 hours.

Start of the Day
The Badge
The Snacks
A space blanket for hyper naps
Lining up the shoot for G4

Here’s a brief run through of how the event went down:

0900 – An overview of the new Kinect SDK is presented by Dan Fernandez and Clint Rutkas.

1015 – Team Chupacabras consisting of Rick Barraza, Dennis Delimarsky and myself begin coming up with an idea for our project.

1205 – We knew we wanted to do something with the Joints API and we’d been working with Windows Phone lately – thus Bunny Hop was born. A multiplayer co-op game where one player uses a Windows Phone as the birds-eye view navigator and the other hops through the maze with a first-person view using the Kinect.

1400 – At this point, Dennis and I had gotten through the mystery of connecting the two clients (Phone and WPF app) to the service.  Rick had a WPF 3D world up and running from scratch. With the mysteries out of the way it was time to write app-specific code.

2100 – Correct data is now flowing from Phone to server and on to WPF app, as well as from WPF app to server to Phone App. Direction of the player comes from the phone using accelerometers, hopping (moving forward) and grabbing and dropping objects comes from the WPF app using the Joints API.  Rick begins integrating the Kinect-enabled WPF app with the networked WPF app.

0530 – After hours of debugging, fine-tuning, eating snacks and hiding under space blankets, we decide to try and grab some sleep before the big live show.

0815 – Arrive back at Code Camp (showered, somewhat refreshed) we still need to clean up graphics on both Phone and WPF app.

0845 – Bus shows up to take us to Studio 20 for the Live event, finishing up graphics in the Lobby.

1000 – We head into the studio to demo our brand new Phone/Kinect game on Channel 9 Live. You can see our demo by viewing this video and fast forwarding to minute 40.

1030 – Back to the Code Camp to talk to the press about our experience:

Here’s a screenshot of the Bunny Hop game in the bird’s eye view on the Phone, followed by the first person view in the Kinect-enabled WPF app.

Bunny Hop - bird's eye view

Bunny Hop - first person view

In Conclusion..
It was a great experience and the Kinect SDK is really well put together, its very easy to get started with. Although our game was hastily put together, I am very happy with the results.  The big win though was taking time out to go through the process of building a Kinect-enabled app and thinking through the new dimension the Kinect adds to software development.

And thanks to Jessica Chobot for enhancing the name. It is no longer just “Bunny Hop”, it has been renamed “Super Hyper-Cute Bunny Hop”. Hop along now.

Posted in Client Technologies, Experiments, Storytelling | Tagged , , , | 5 Comments

The Book of CSS3 – take me to the future! …which is right now

The Book of CSS3, from Peter Gasston, is your ticket from understanding the long-lived CSS2.1 to the new world full of possibilities with CSS3.

The Book of CSS3Yes, there are issues understanding which features of CSS3 have been properly recommended and are currently supported by modern browsers.  But this is where Peter’s extensive knowledge of the past, present and future direction of CSS3 transcribed into this book is so valuable.

His writing style is clear, concise and casual and although the samples are not pulled from real-world apps, their brevity keeps the focus on the feature of discussion. Walking through each example step-by-step, Peter manages to cover the major features while explaining how to implement them successfully in each browser.

After reviewing the past and present, the book ends with Chapter 17 “The Future of CSS”. Although most features discussed have limited or no implementations, it’s fun to look at new ideas and the chapter acts as a reminder that CSS is ever expanding and becoming more and more powerful.

You may have other display technologies and frameworks of choice, but you would be remiss to ignore the current and future most popular display technology.  This book is a great guide to updating your CSS knowledge, ensuring you are not left behind.

Posted in Book Reviews, Client Technologies | Tagged , , | Leave a comment