Thursday, December 26, 2013

Running Man Quiz app is in the Google Play Store now!

Hooray!
Finally, there is an app "Running Man Quiz" available in the Google Play Store.



For those fans of the Running Man Variety Shows, now it is time to show your craziness towards the Running Man - answering all the quizzes in the app :)

Overall, there are four categories of quizzes:

 

 

a) Relationship

- Basically, you are required to guess the names, nicknames of the RM members. Remember, the staffs are included too (eg: Who is the Floor director of the RM show?)

 

 

 

b) Music

- If you are really a Running Man Show maniac, this is definitely not a problem to you. Still remember the "Angry Bird" background music? Which member does the music belong to?

 

 

c) Medal

- Episodes by episodes, you will be asked about who (or which team) won the final game? (eg: who is the last survival of the name tag tearing game in the episode xxx?) I admit this is a bit challenging. But fret not, hints are given sometimes. :)

 

 

d) Storyline

- Similar to the Medal category, the quizzes in the storyline are based on the episodes. Here, the questions will be more details, and definitely test your memories, lol.


So, what to hesitate? Quickly grab the Running Man Quiz game at the play store~

Tuesday, December 24, 2013

Actionscript ProgressBar DIY in Starling Framework

The Starling Framework doesn't come with the built-in Progress Bar, but the Feathers framework does.

However, i find that it isn't that hard to create a progress bar ourselves, and to be used with the Starling Framework.

Here, what we need to do is to create a ProgressBar class:

    public class ProgressBar extends Sprite
    {
        private const BAR_WIDTH:int = 100;
        private const BAR_HEIGHT:int = 30;
        public var qdMax:Quad; // a static bar
        public var qdMove:Quad; // a moving bar
       
        public function ProgressBar()
        {
            this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        }
       
        private function onAddedToStage():void
        {
            this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
           
            qdMax = new Quad(
BAR_WIDTH,BAR_HEIGHT,0xf0f0f0);
            qdMove = new Quad(1,
BAR_HEIGHT, 0x990000);
            addChild(qdMax);
            addChild(qdMove);
        }
       
        public function updateBarMove(_ratio:Number):void
        {
            qdMove.width = (_ratio)*qdMax.width; //adjust the width
        }
    }

Here, we have a very simple class. The main thing to note here is that, there is a function updateBarMove which takes the parameter of a 'ratio', ranging from 0 to 1, and is to be called from time to time to update the visual bar status. Any example of using this? Here it is:

How to show the progress bar while playing the audio files in Starling Framework (AS3)?

Yup, with the class defined above, we can easily display the progress of the audio files when it is played or paused. Here's the original source as your reference. Now with the onEnterFrame function, it can be performed with ease.

So, assume that you have a button switching from "play" to "pause" and vice versa. When it is "played", we dispatch the Enter Frame Event, as shown below:

      public var pBar:ProgressBar;
    public var sound:Sound;
    public var sc:SoundChannel = new SoundChannel();
    public var musicLength:int;

       private function onEnterFrame(e:EnterFrameEvent):void
    {
       var ratio:Number = sc.position/musicLength;
           
       if(ratio >= 1) //when the audio playing finishes
       {
           sc.stop();
           sc = sound.play(0);
           sc.stop();
           this.removeEventListeners(Event.ENTER_FRAME); //stop updating
       }
           
       pBar.updateBarMove(sc.position/musicLength); //passing a ratio
   }


Here you go, the progress bar is created!

Saturday, December 21, 2013

How to load TextureAtlas with the AssetManager in Starling Framework?

From the Hsharma's tutorial, we have learned that using a Sprite Sheet to load the textures is crucial to ensure a great performance. Next, you may want to ask, if the Sprite Sheet is too big to be loaded at run-time, are we able to tell the users, "hey, we are loading the resources, please wait a minute" to serve as a buffer before we proceed to the next screen/activity?

Good news. Tracking the process of loading the textures or other assets is made possible with the AssetManager class in the Starling Framework. In fact, the original tutorial could be found at here. In this post, particularly, i would like to show how to load TextureAtlas with the AssetManager.

Similar to loading the normal textures, to begin loading the TextureAtlas, let's have a class EmbeddedAssets.

public class EmbeddedAssets
{
     // Texture
     [Embed(source="../media/graphics/mypng.png")]
     public static const mypng:Class;
       
     // XML

     [Embed(source="../media/graphics/myxml.xml", mimeType="application/octet-stream")]
     public static const myxml:Class;

}

In the EmbeddedAssets class, we embed the TextureAtlas and the TextureXml as usual. Yup, just embed them as usual. Then, we could just use the AssetManager to load it (with the enqueue function).

public var assets:AssetManager = new AssetManager();

.....
assets.enqueue(EmbeddedAssets); //yes, enqueue the entire class
assets.loadQueue(function(ratio:Number):void
 {
    trace("Loading assets, progress:", ratio); //track the progress with this ratio
    if (ratio == 1.0)
          initGame();
 }); 



 Finally, in the initGame and the subsequent functions, we are able to load the texture with the function getTexture. For example, assume that you have a texture named "playButton" in the TextureAtlas, you can easily load it with the line below:

 var texture:Texture = assets.getTexture("playButton");

Isn't that very convenient?

Friday, December 20, 2013

Creating a timer with the Actionscript onEnterFrame

For those who are Actionscript-savvy, the "onEnterFrame" Event is a familiar term. It is in fact an elegant way of handling the animations in the game.

This post, is particularly a demo of how do i use the AS3 "onEnterFrame" to replace the class Timer (which is in the package flash.utils). You might think that this is redundant. But i really favor the way the "onEnterFrame" perform this with ease, while you can implement the other animations simultaneously.

Here's a snippet of the "onEnterFrame" function. What it does is that, the object is able to perform an animation A on each frame, while performing another animation B at an interval of one second (adjustable).

private var timePassed:Number = 0;
private var startInt:int = 1;
private function onEnterFrame(e:EnterFrameEvent):void
{
     timePassed += e.passedTime;
     if(startInt < 10)
    {

         //doAnimationA();
         if(Math.floor(timePassed) == startInt)
        {
             startInt++;

             //doAnimationB();
        }
     }
     else
    {

        this.removeEventListeners(Event.ENTER_FRAME); //clean the event
     }
 }

One thing to note is that, the data type of the timePassed has to be "Number", but not "integer". In the code, after passing 10 seconds, the enterframe event is removed.

Monday, December 16, 2013

Sound effect resources for Android Games

In case you are wondering where to look for free sound effect resources for Android Games, here i have a recommended link.

There are 3 main reasons i pick this sound effect resources instead of the others:

a) Resourceful solutions

The different types of sound effects are categorized clearly at the left, listing:
  • Pickup/Coin - eg: Mario Coin
  • Laser/Shoot - eg: Space shooter
  • Explosion - eg: tower defense bomb
  • Powerup - eg: RPG level up
  • Hit/Hurt - eg: Streetfighter / King of fighter attack
  • Jump - eg: Mario jump
  • Blip/Select
  • Randomize
  • Mutation

b) Intuitive and flexible

By clicking the button, it will generate a sound effect of your choice. Each click will generate a different sound. Basically you can perform unlimited clicks until you hear the one of your favorites. Furthermore, Each sound effect generated is tunable with a number of attributes:
  • Attack Time
  • Sustain Time
  • Punch
  • Decay Time
  • Compression
  • Frequency
  • Frequency cutoff
  • etc ....

c) Free for all

If there is a Facebook "Like" button, or a Google "+" button, i won't be hesitating to share this to all my friends. You can easily export all the sound effects generated for free. YES, you are not reading the typo. There are really some Samaritans out there researching and creating free products for us!

I believe most of us are not sound engineers, so having this resource would be definitely a helpful one.

Note: If you are going to load the sound effects into the Flash Builder, remember to perform the up-sampling / down-sampling the frequency of the audio files with the appropriate software, as mentioned in previous post.