Reader small image

You're reading from  Gideros Mobile Game Development

Product typeBook
Published inNov 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781849696708
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Arturs Sosins
Arturs Sosins
author image
Arturs Sosins

Arturs Sosins is a developer living with his wife Anna and son Tomass. He has a Master's degree in Computer Science and even though he is working as a developer full time, he still loves coding and shares his knowledge with others in his spare time. In his last years at the university, he started chasing the dream of creating his own mobile games for fun and personal satisfaction in his spare time. After trying out lots of different cross-platform frameworks for mobile game development, he found Gideros SDK in January 2012 and liked it so much that he decided to stick with it when developing his games. In the summer of 2012, he founded a group of like-minded developers/designers who go under the indie label Jenots.com (http://jenots.com/). They released Mashballs (http://jenots.com/mashballs), their first game, in September 2012 and are currently working on a couple of bigger game projects. As there was a lack of learning materials and tutorials for Gideros and writing was one of the his favorite hobbies, he started creating different tutorials on how to accomplish simple things in Gideros. This led him to create his new blog http://appcodingeasy.com. Due to popularity of his tutorials and the support he provided on the Gideros community forum, he became the most active community member. In February 2013, the Gideros team offered him the position in the Gideros developers' team, where he has been working since then, while continuing to work on games in his spare time.
Read more about Arturs Sosins

Right arrow

Chapter 4. Polishing the Game

Now that we have the basics covered and have a working prototype of our game, let's improve it a bit by adding some of the most common enhancements to both the look and feel of our game and its gameplay.

This chapter will describe how to spice up our game to make it more appealing and alive. Topics covered in this chapter are:

  • Adding background music and sound effects to the game

  • Using high scores for gamification

  • Animating game elements

  • Tweening to make the game more dynamic

  • Improving gameplay by adding gestures

  • Providing ways to players to interact with game elements

Adding sounds


Although usually underrated by developers, background music and sound effects are an important part of any game. It sets up the mood and compliments the gameplay. But that's aesthetics. What we need to learn is how to set up background music and sound effects in Gideros.

Gideros API for playing sounds is pretty straightforward. First, we load sound by creating the Sound class instance.

local sound = Sound.new("mysound.mp3")

And then we play this sound by calling the sound:play() method.

Note

In Gideros, a good practice is to use MP3 format for background music or sounds that do not require immediate play. This is because MP3 is a compressed format and more resources would be required to uncompress it.

For sound effects and other sounds that do require immediate play, you should use WAV files, because this file format is uncompressed and can be read and played immediately.

But what we need to do is to provide the ability to turn the sounds off and on as well. So what we will do here...

Adding high scores


Implementing high scores is a must for almost every game to make players compete with each other or to make players replay levels to improve their result. So let's modify our GameManager class to also manage score for each level.

Inside our GameManager class createLevel method, we already stored default score and time values, so now we only need methods to set and retrieve them.

First, we will create a method to set the score, which would simply take pack and level number and the user score as the parameters, and return true to indicate that the user has beat a high score or false if the user'sscore is lower than the highest score.

So, as done previously for almost each GameManager method, at first we try to load the pack and create the level information if we need. Then we check if the user's high score is higher than the saved one; and if it is, we save the new score and time when it was achieved. Then we return true, else we simply return false.

function GameManager:setScore...

Creating animated game elements


Animations are a vital part of improving a game. They make your game look more polished and alive, which appeals to many players out there and that is why animation is one of the ways in which we will improve our game.

There are two main ways to animate elements in Gideros:

  • Using frame animations and MovieClip class

  • Tweening the properties of object using GTween class

Frame animations using MovieClip

First let's create a frame animation for our TouchBall. To create a MovieClip instance we need to pass the definition of the frames which will appear in animation.

Each row of animation contains information, such as, {1, 10, sprite}, which contains position number of start frame, position number of end frame, and the sprite inherited object that will be displayed during this span of frames (from start frame to end frame).

If you want to display the next sprite object without overlapping with previous one, we add another definition to the table by using the same start...

Improving gameplay


There are a lot of ways to improve the player experience, starting from the gameplay of the game logic itself to polishing the interface of the rest of the game scenes. It was difficult to decide what exactly to include showing some cool improvements. So, I decided to make one improvement to the pack selection. This improvement will allow switching between packs using swipe gesture. And there are also other improvements to show you how to implement the key element of Mashballs game, controlling main ball using touch input in a magnet-like style..

Changing level packs by using the swipe gesture

Currently we can only switch the packs by clicking on the corresponding button. But for most of the mobile users, it might seem pretty natural to switch these kinds of screens by swiping their finger to the left or right direction. Let's implement this for user's convenience.

Starting with MouseDown

Let's start with a handle for the MOUSE_DOWN event. Inside it we will set the self.isFocus...

Summary


We have enhanced our game with more stylish controls, such as using swipe gesture on packs and controlling the main game element with a magnetic force created by our own fingers touching the screen. We have also gamified our game with high scores and added tweens and frame animations to juice it up; and let's not forget background music and sounds that we added to complement our game.

Now the game itself is far from finished. But, by now you have learned all the basics that you need to create a game using Gideros. You have also learned about the additions that you can do to improve it visually, acoustically (aurally), and aesthetically.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Gideros Mobile Game Development
Published in: Nov 2013Publisher: PacktISBN-13: 9781849696708
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime

Author (1)

author image
Arturs Sosins

Arturs Sosins is a developer living with his wife Anna and son Tomass. He has a Master's degree in Computer Science and even though he is working as a developer full time, he still loves coding and shares his knowledge with others in his spare time. In his last years at the university, he started chasing the dream of creating his own mobile games for fun and personal satisfaction in his spare time. After trying out lots of different cross-platform frameworks for mobile game development, he found Gideros SDK in January 2012 and liked it so much that he decided to stick with it when developing his games. In the summer of 2012, he founded a group of like-minded developers/designers who go under the indie label Jenots.com (http://jenots.com/). They released Mashballs (http://jenots.com/mashballs), their first game, in September 2012 and are currently working on a couple of bigger game projects. As there was a lack of learning materials and tutorials for Gideros and writing was one of the his favorite hobbies, he started creating different tutorials on how to accomplish simple things in Gideros. This led him to create his new blog http://appcodingeasy.com. Due to popularity of his tutorials and the support he provided on the Gideros community forum, he became the most active community member. In February 2013, the Gideros team offered him the position in the Gideros developers' team, where he has been working since then, while continuing to work on games in his spare time.
Read more about Arturs Sosins