1

Sharing Cinemagraphs in your Windows Phone 8 App (Featured Article)

Sharing Cinemagraphs in your Windows Phone 8 App by AlexSorokoletov

Wp ss 20130407 0005.png

Nokia provides all Windows Phone 8 devices with a very nice app called Cinemagraph which allows one to create, edit and share animated pictures, or “cinemagraphs”. You can find out more about Cinemagraph on this blog entry.

This article explains how to add Nokia Cinemagraph sharing to your Windows Phone 8 application. In other words, after reading this article you will know how to share “Cinemagraphs” in your own applications on Windows Phone 8.

MonoGame on Windows Phone 8 Post-Processing Your Game (Featured Article)

MonoGame on Windows Phone 8 Post-Processing Your Game by this_is_ridiculous

Water.png

When you develop a game, at some point, you start thinking about adding special effects to your graphics pipeline. Doing this is beneficial for several reasons:

  • For having effects that cannot be created by an artist (refraction, reflection, water effects)
  • For setting additional mood for a gameplay (bloom, blur, filter effects)
  • For making your games just look cooler (all sorts of distortion effects)

This article explains how to compile and use shaders with MonoGame on Windows Phone 8 for post-processing.

Designing & Optimising Graphics for your Series 40 app (Featured Video)

Are you wondering what to consider when designing and optimising graphics for your Series 40 application? Mikko Kaipio, Senior UX Designer, provides you with tips and best practices for handling graphics in your Series 40 applications.

He also explains the key items to take into account when porting your Android application graphics to the successful Nokia Asha family of Series 40 phones.

More information about Series 40 UX resources can be found here: http://bit.ly/Qx757l

Explore the app examples used in this video:

Silverlight animation with Expression Blend (and no code) (Featured Article)

Silverlight animation with Expression Blend (and no code) by izinin

Microsoft Expression Blend (included in the Windows Phone SDK) is a powerful visual design tool for making visible elements and effects in Silverlight applications. It can be used simultaneously with Visual Studio on the same opened project – modifications made in either tool become immediately available in other.

This tutorial shows how to create powerful object animation using Microsoft Expression Blend.

Grouping graphics into canvas

Read the article for more information: Silverlight animation with Expression Blend (and no code)

Windows Phone Native C++ and DirectX – First Direct3D App, setting up Touch and Sensors (Featured Article)

Windows Phone Native C++ and DirectX – First Direct3D App, setting up Touch and Sensors by jumantyn

This week’s featured article shows us the basic steps of creating a first native Direct3D app. We take a look at the files created in the project template and also show you how to utilize touch input and Windows Phone sensors i.e. accelerometer and gyroscope.

DX SS 04.pngDX SS 05.png

Let us know how you found this article!

Series 40 UI Component Demos (Featured Project)

ImageSeries 40 UI Component Demos is a J2ME based suite, which installs 10 different demo applications for the purpose of demonstrating the capabilities of the new series 40 Java based UI.

This example is guide to both designers and developers.  Designers can get the idea on how the UI elements look like on real device and developers can have a hand on experience on how to use the LCDUI components in applications.

ImageImage

The example includes demo apps / icons for:

  • Lists
  • Text
  • Dialog
  • Canvas
  • Form
  • Category
  • Ticker
  • Confirmation
  • Empty content
  • Zoom

This example could be a great reusable UI Component set for developers.  Though the example is targeted for Series40 devices but most of its components like Lists, Text, etc runs on Symbian devices also.

– Somnath Banik (on behalf of the Projects Moderation team)

Completing the Casual Game Move from QML to XNA

In my last post, I discussed how to build the “Kolobok” main
character in our casual game for Windows Phone 7 from the Kolobok.qml file from
the Symbian phone version.  I also
discussed the method my team used to animate the fire obstacle by rotating
through a list of texture images at a set frame rate.

In this blog, I will finish up the application by showing
how to map the QML MouseArea inputs for the navigation buttons into the input
handlers for the XNA game object. Next I will discuss how to play the sounds
associated with Kolobok’s movement and collision with obstacles.

Input in the QML version of the application is strictly
event driven. Normally we would place button images on the screen in the game
board object and over a MouseArea to catch a user mouse event using an
“anchors.fill” property. This would work for individual buttons but would not
detect two buttons pressed at the same time. For this we need a MouseArea that
would handle Multi-touch events.

QML does not have a predefined element for multi-touch,
however the C QDeclarativeItem provides multi-touch input events. Therefore
we chose to implement a QDeclarativeItem multi-touch object in C and bind it
to QML as a new element. To simplify the implementation we combined the image
and multi-touch elements into one element called MultiTouchItem that has an
image source property and delivers user events as pressed() and released()
signals. These signals are directly connected to the Kolobok characters key handling
methods.

In Windows Phone 7 we will use the event handling methods
and implement the multi-touch events as synchronous tests in the game object’s
Update method. Multi-touch inputs will be passed onto the Kolobok character
game piece’s KeyPressed and KeyReleased methods.

For each game action button in the QML game, we create a
MultiTouchItem object that overrides the QDeclarativeItem::sceneEvent method
and catches the QEvent::TouchBegin and QEvent::TouchEnd events.  The object also catches the Mouse Press and
Mouse Release events in case a non-touch screen input device is used. The
screenEvent method is shown below:

bool MultiTouchItem::sceneEvent(QEvent *event)

{

    switch (event->type()) {

    case QEvent::TouchBegin:

        emit pressed();

        break;

    case QEvent::TouchUpdate:

        break;

    case QEvent::TouchEnd:

        emit released();

        break;

    case QEvent::GraphicsSceneMousePress:

        emit pressed();

        break;

    case QEvent::GraphicsSceneMouseRelease:

        emit released();

        break;

    default:

        return QDeclarativeItem::sceneEvent(event);

    }

    return true;

}

The events emit the appropriate released() or pressed()
signals that are communicated to the Kolobok Element .

In the XNA Game object Update() method, we call the
buttonEvent() method that will poll for multi-touch input and then call the
input methods in the Kolobok.cs file. Multi-touch input is collected in a
TouchCollection container object that can be read using the touch panels
GetState() method. The buttonEvent method is shown below:

void buttonEvent()

        {

            // Windows phone controls

            TouchCollection state = TouchPanel.GetState();

            foreach(TouchLocation
tl in state)

            {

               
// Handle key pressed

               
if (tl.State == TouchLocationState.Pressed)

               
{

                   
if (positonInArea(tl.Position,
closeBtnArea))

                        this.Exit();

                   
else if
(positonInArea(tl.Position, leftBtnArea))

                        gameBoard.keyPressed(GameBoard.Key.Left);

                   
else if
(positonInArea(tl.Position, rightBtnArea))

                        gameBoard.keyPressed(GameBoard.Key.Right);

                   
else if
(positonInArea(tl.Position, upBtnArea))

                        gameBoard.keyPressed(GameBoard.Key.Up);

               
}

               
// Handle key released

               
else if
(tl.State == TouchLocationState.Released)

               
{

                   
if (positonInArea(tl.Position, leftBtnArea))

                        gameBoard.keyReleased(GameBoard.Key.Left);

                   
else if
(positonInArea(tl.Position, rightBtnArea))

                        gameBoard.keyReleased(GameBoard.Key.Right);

                   
else if
(positonInArea(tl.Position, upBtnArea))

                        gameBoard.keyReleased(GameBoard.Key.Up);

               
}

               
else if
(tl.State == TouchLocationState.Moved)

               
{

                   
TouchLocation previous;

                   
if (!tl.TryGetPreviousLocation(out previous))

                        return;

                   
if (positonInArea(previous.Position,
leftBtnArea) &&

                       
!positonInArea(tl.Position, leftBtnArea))

                        gameBoard.keyReleased(GameBoard.Key.Left);

                   
else if
(positonInArea(previous.Position, rightBtnArea) &&

                       
!positonInArea(tl.Position, rightBtnArea))

                        gameBoard.keyReleased(GameBoard.Key.Right);

             
      else
if (positonInArea(previous.Position, upBtnArea)
&&

                       
!positonInArea(tl.Position, upBtnArea))

                        gameBoard.keyReleased(GameBoard.Key.Up);

               
}

            }

 

        }

 

In both the QML and XNA versions of the game, we pass inputs
from the touch device into the Kolobok object’s input methods, and then call its
doMovement() method to update the Kolobok’s position on the screen and respond
to any collisions with other game pieces.

Once we handle input and process game action, the only thing
left to do is play the game sounds and music for each game action.

In the QML game, we create a SoundPlayer object that
contains QAudioPlayer objects from the multimedia APIs in Qt Mobility. The
SoundPlayer contains audio files that play the various sounds depending on the
type of game action. The two main sounds are “Groan” and “Boing” generated when
the Kolobok experiences health decreasing events or collisions with another
game piece.

Sound player APIs are usually very similar and easy to use.
We create the object, set the format, load the sound file, and when we are
ready, call the play or start method.  For QML we create a QAudioPlayer and a
QMediaFormat object. We then set the Format object’s media attributes, bind it
to the Player object, and then call play. The code looks something like this:

QAudioFormat m_format;

m_format.setSampleRate(22050);

m_format.setChannelCount(1);

m_format.setSampleSize(16);

m_format.setCodec("audio/pcm");

m_format.setByteOrder(QAudioFormat::LittleEndian);

m_format.setSampleType(QAudioFormat::SignedInt);

m_boingOutput = new QAudioOutput(m_format,this);

m_boingtFile.setFileName(":/sounds/boink.raw");

 

if (m_boingOutput)

    if (collided) {

        if(m_boingPlaying) return;

        m_boingOutput->start(&m_boingtFile);

        m_boingPlaying = true;

         }

For XNA we use a SoundEffect object
to accomplish the same thing. The following code provides support for the Boing
sound above:

SoundEffect boingSound = content.Load<SoundEffect>("sound/boink");

if (boingSound != null)

   if (collided) boingSound.Play();

 

Note that the SoundEffect object
doesn’t require us to set the format of the file. The reader figures this out
from the content .Load method. Once we know how to generate the sounds, we can
trigger them from the collision detection code discussed in the previous blog.

This posting completes my blog series
on reengineering a QML casual game to XNA. Next week I will begin the steps
necessary to port a simple twitter application to Silverlight.

Developing the Kolobok Game Piece

In my previous post, I developed the Kolobok game board for
Windows Phone 7 from the QML Bounce game posted on the
projects.developer.nokia.com site. In this blog posting, I will discuss how my
team developed the main Kolobok character along with the Cacti, Fire, and Brick
Wall obstacles. In my next posting, I will discuss the input buttons and
methods and how the game components are integrated into the final game.

The Kolobok character is the central component of the game.
Upon input from the user, the Kolobok will roll across the current tier or
bounce upward to a new tier. If the Kolobok encounters an obstacle, such as a
brick wall or cactus, the Kolobok will bounce backwards to a previous
position.  Fire will impede the
characters progress while reducing its health.

As we discussed in the previous posting, the Kolobok
character is defined in the class Kolobok in the file Kolobok.cs.  The class Kolobok is derived from the
GraphicItem class that holds important common properties such as object width,
height, position, texture, rotation angle, and opacity. All game pieces,
including characters and obstacles, are derived from this GraphicItem class.
The GraphicItem class also supports rudimentary animations for the moment of
the Kolobok or the flicker of the flame obstacle.

The original QML file kolobok.qml is an Ellipse Element that
contains the “Kolobok’s” properties and its Image, a non visible Timer element,
Key handlers, and javascript methods that respond to user events, moves the Kolobok
character, detects collisions, and updates the game statistics based on the
collisions with obstacles.

import QtQuick 1.0

import Shapes 1.0 

Ellipse
{

    id: kolobok

    // properties
   

    Image {

        id: kolobok_image

        objectName: "kolobok_image"

        x: 0; y: 0

        width: 100; height: 100

        source: ":/images/face-smile.png"

        smooth: true

        opacity: 1.0

    }

   

    Timer {

        id: timer

        interval: 25; running: false; repeat: true

        onTriggered: doMovement()
    }

       Keys.onPressed: { 

        if (event.isAutoRepeat)

            return;

        keyPressed(event.key);

    }

    Keys.onReleased: {

        if (event.isAutoRepeat)

            return;

        keyReleased(event.key);

        }

        // methods
       
}

QML does
not have an Ellipse Item defined, so we have defined an EllipseItem class that
draws an Ellipse in the C file level.cpp and registered this class in the
“Shapes” library as an Item named Ellipse.

The
KeyPressed and KeyReleased methods referenced above will respond to use input
events. If the input is one of the arrow keys, then the doMovement() method is
called, which will move the Kolobok character accordingly.

Collision
detection in the QML application is handled by the Qt Graphics View built-in
collision detection mechanism. The doMovement() method in kolobok.qml will call
into a method in the level.cpp file that will extract the list of items that
collide with the Kolobok and then update the state of the Kolobok accordingly.

The newly
created Kolobok.cs file will also contain the Ellipse, the Kolobok’s properties
and its image, key handlers, and support methods. The timer is an integral part
of the main event loop in XNA and so it is not explicitly defined in C#.
Because graphics objects are not implicitly self drawn or updated in XNA, we
will need to implement the Kolobok’s Initialize, Draw, and Update methods. The
remaining support methods are based on the original Javascript code, but
rewritten in C# using the XNA libraries.

The Initialize
method is very simple and merely initializes the Kolobok’s properties to their
starting values. The Update method will call doMovement() which will check the
user input for an arrow key press and will move the Kolobok character
accordingly. The update() and Draw() methods are shown here:

        public override void Update(GameTime gameTime)

        {

            base.Update(gameTime);

 

            // TODO: Add your update logic here

            doMovement();

 

            if (health <= 0)

                health = 100;

        }

 

        public override void Draw(SpriteBatch spriteBatch)

        {

            // Set up the color

            Color color = new Color(opacity, opacity, opacity, opacity);

 

            // Set up the origin point

            Vector2 origin = new Vector2();

            origin.X = Texture.Width / 2;

            origin.Y = Texture.Height / 2;

 

            // Set up the render rectangle

            Rectangle rect = new Rectangle(Rect.X + Rect.Width / 2,

                                           Rect.Y + Rect.Height / 2,

                                           Rect.Width, Rect.Height);

 

            spriteBatch.Draw(Texture, rect, null, color, RotationAngle, origin,

                              SpriteEffects.None, 0f);

 

            // Draw the health

            spriteBatch.DrawString(healthFont, "Health:" + health,

                                    new Vector2(20, 20), Color.White);

        }  

Key input
is handled through the KeyPressed() in KeyReleased() called by the input
handler in the game object’s update method. The remainder of the method, called
collisionDetection(), uses the XNA collision detection library to determine if
the Kolobok character is colliding with an obstacle and then updates the Kolobok
state.

The
doMovement(), keyPressed() and keyReleased(), and updateCollisions() methods
from kolobok.qmls javascript code are simply re-implemented in C#.

In QML,
the code to read the game layout database and present it to the game board is
written in C in the file level.cpp. The method load() in the C file uses
the Qt QXmlStreamReader to parse an XML database file and for each vertical
level on the game board stores a string containing a character for each
obstacle. The vertical level strings are stored in QVector container called
“map”. These level strings are used to build the game board as described in the
previous blog. The load method is shown below:

bool Level::load()

{

   

    m_rowCount = m_columnCount = 0;

    m_map.clear();

   

    QFile file(":/level/level.xml");

    if (!file.open(QFile::ReadOnly | QFile::Text)) {

        qDebug() << Q_FUNC_INFO << file.errorString();

        return false;

    }

   

    QXmlStreamReader xml(&file);

    if (xml.readNextStartElement()) {

        if (xml.name() == "level") {

            while (xml.readNextStartElement()) {

                if (xml.name() == "layer") {

                    const QString text = xml.readElementText();

                    m_map.append(text);

                    m_rowCount;

                    m_columnCount = qMax(m_columnCount, text.count());

                }

            }

        }

    }

In the
Windows Phone version of the game, level.cs contains a very similar load function.
Here we use the XmlReader class to read the XML data file and a List container
class to store the level strings. Note the similarities between the two
methods:

public static bool load(string
filePath)

        {

            // Clear the level’s old data.

           
mRowCount = 0;

           
mColumnCount = 0;

           
mMap.Clear();

 

            // Open the level xml file

            XmlReader reader = XmlReader.Create(filePath);

            while (reader.Read())

            {

               
if (reader.Name == "layer")

               
{

                   
string text = reader.ReadInnerXml();

                   
mMap.Add(text);

                   
mRowCount ;

                   
mColumnCount = Math.Max(mColumnCount,
text.Count<char>());

                }

            }

            return true;

        }

 

Now that
we implemented the Kolobok character and the movement logic behind the game,
the only remaining parts are to process input from the user and play background
music and sounds. In my next blog, I will pull the rest of the application
together and show how I completed the port.

 

Got 4.7 Working Using NokiaQtSDK and Qt for Symbian

I built several simple examples that used Qt 4.7 features and ran on my N8 phone. What was more interesting to me was downloading some QML programs to the phone and running them using the qmlviewer included in the zip file above that contains the device libraries. 

Here are the steps I used to get Qt 4.7.0 on Symbian working with the abbreviated SDK that comes with the Nokia Qt SDK version 1.0.1:

1) Download the Qt 4.7.0 for Symbian 3 SDK and device libraries from the Qt and Forum Nokia Sites:

Qt 4.7 Open Source for Symbian S60

Symbian Qt 4.7 SIS files 

2) Download and install the NokiaQtSDK version 1.0.1 from the forum nokia site:

Nokia Qt SDK Version 1.0.1

3) Once it is installed copy the directories c:\nokiaqtsdk\symbian\SDK\epoc32 and c:\nokiaqtsdk\symbian\SDK\perl to another SDK directory. I installed mine in c:\Qt\4.7.0\Symbian\SDK.

4) run the qt-symbian-opensource-4.7.0-s60.exe installer and select the option to install into other sdks. You will be given a list of empty install locations. Enter your SDK directory into the first one. This will overwrite Qt in that SDK\epoc32 directory (e.g. enter c:\Qt\4.7.0\Symbian\SDK) and install Qt into C:\Qt\4.7.0.

5) run creator and under the tools menu, select options and navigate to the qt tab on the left. Add a new version of Qt to creator. The qmake file will be in c:\Qt\4.7.0\bin\qmake.exe.

6) Fill in the remaining fields (leave the carbide field blank). The SDK field should be c:\Qt\4.7.0\Symbian\SDK and the CSM/gcce field should be c:\nokiaqtsdk\symbian\SDK\gcce (there is no reason to copy the gcce directory.)

7) unzip the Qt_4_7_for_Symbian_3_Developer_Version_v1_0_en.zip file. Inside are two more zip files. Unzip the Qt 4.7 for symbian^3.zip file and install all the sis files to your phone. If you have OVI suite installed, you can do this by double clicking on each sis file and then following the install directions.

Now you have a complete setup. If you installed the qmlviewer.sis you can download QML applications to your phone and run them. To download the qml files, exit from OVI suite and use your phone as a mass storage device. 

 

Qt for Symbian Hands on Training for the N8

Throughout the fall I will be teaching a series of workshops on Qt for Symbian using the N8 around the U.S. and Canada. We have already held two well attended classes in Boston and Toronto. More information about the workshops can be found below If you live and/or work in North America, I hope to see you at one of the remaining workshops.

Forum Nokia and Integrated Computer Solutions (ICS), a Qt certified training and consulting partner, are providing an intensive two day hands-on, classroom style coding workshop that will train developers how to use Qt to develop mobile applications for the new Nokia N8. Attendees will learn how to create mobile applications with Qt by using an actual N8. Workshops are currentlyscheduled for Boston, Toronto, NYC, Austin, San Francisco, Seattle, and Vancouver with more cities being added soon.

 The workshop schedule: 

More info can be found at http://www.ics.com/learning/qtforn8

 Additional Qt training can be found at the ICSNetwork Site at http://www.ics.com/learning/icsnetwork