A couple of months ago I wrote that I was learning to
program in Silverlight on the Windows Phone 7 platform and share my experience
with porting applications from QML to Silverlight. Since then my team and I
have ported two demonstration applications from QML on Symbian to Silverlight. As promised, I am going to share my experience
to encourage others to do the same.
During the past few weeks my team ported two applications
from QML to the Windows Phone. The first is a simple side scrolling casual game
and the second a simple Twitter application. While both applications are
complete, we are still working on the notification piece of the Twitter app
that will update the home screen tile with the count of unread tweets.
The casual game application, called QmlBounce, was
originally written in QML and is available from the URL https://projects.developer.nokia.com/qmlbounce.
We implemented the game using the Windows Phone 7 XNA framework. If you are not
familiar with XNA, it is a C# set of classes and libraries that simplifies the
creation, transformation, and animation of graphical items rendered as Sprites.
The programming model for game components is very similar to Graphics View in
that both provide lightweight objects that draw themselves. Graphics View items
are painted in the paint method, while XNA game components draw themselves in
their Draw method.
To simplify the porting process, we created a new C# class
called GraphicsItem that implements many of the properties and methods of the
Qt QGraphicsItem. We then could use this class to easily implement each of the
graphics objects created in QML.
The Twitter application port was straightforward. Our
graphics team implemented the window, pages and dialogs using the Windows Phone
Visual studio designer. We chose to use a Pivot element , because it closely
mirrored the multi-page look and feel we implemented in QML. The original QML
implementation was hard because we needed to implement each of the controls
along with the page and page stack ourselves. The release of the Qt Quick
Components simplifies this effort as it provides these higher level Elements as
In my next blog, I will provide a step by step description
of how we implemented the Casual Game. I will start with overall game design
and then work my way though the individual objects, properties, and methods.