Win an Ipad
  Blog   Coloring game for iO ...

19.9.2012

Coloring game for iOS, Android and Bada in three hours

The time is the developer’s most important resource. Porting an application for at least 80% of currently used devices takes just too much time. In following blog post I am going to show how to make the development process more effective using Moscrif SDK. The Moscrif SDK allows porting the application or the game for iOS, Android and Bada with only one code.

To demonstrate how to use Moscrif I am going to show you how to create a coloring game.

The main class for game development is the Game class. Scenes with several layers are inserted afterwords into the game. The scene fills the whole screen and is used to create a practically independent part of the game (f.e.: menu and playground). The layers are used to combine or draw more similar elements together.

Our game has one scene with two layers: first for coloring image and second for lines drawn by user.

When the user taps the screen, a layer for users drawing (called PaintingLayer) calls pointerPressed method, which saves the first point of a line.

Example: start a new line

function pointerPressed(x, y)
{
    this._lastPoint = {
        x   : x,
        y   : y,
    }
}

When user moves his finger on the screen, the PaintingLayer calls pointerDragged method. This method finishes the previous line and starts new line.

function pointerDragged(x, y)
{
    if (this._lastPoint) {
        this._lines.push(new Line({
            color   : this.actualColor,
            width   : System.width / 48,
            start   : this._lastPoint,
            end     : { x : x, y : y},
        }));
        this._lastPoint = {
            x   : x,
            y   : y,
        }
    }
}

Summary

To keep this post short, only few lines of code were shown. However, the whole source code is available to download here!

Write a Comment (0)
Subject
Please complete this mandatory field.
HTML Tags Not Allowed!
Comment
Please complete this mandatory field.
Author

Author latest blogs