Friday, 25 April 2014

Working Processes: Finalising The Game - Adding reset and tweet button to end of the game.

Upon completing the game, I decided it would be a good idea if the user would be able to restart the game and play it again.

I also wanted to make it so that the user would be able to tweet out their time to their friends.

I used the following code for the buttons:

// ---------Buttons---------
//Reset Button
reset_btn.addEventListener(MouseEvent.CLICK,resetListener);
function resetListener(ev:MouseEvent):void {
    gotoAndStop("enterName");
}
//Tweet Button
tweet_btn.addEventListener(MouseEvent.CLICK,tweetListener);
function tweetListener(ev:MouseEvent):void {
    navigateToURL(new URLRequest("http://twitter.com/home?status= I just completed The Waiting Room in "+fl_MinutesElapsed + " Minutes and " + fl_SecondsElapsed +" Seconds!! BEAT THAT! http://tinyurl.com/mflhvk4"),'_blank');
}



I am happy with the results.

Something important to mention is that the Tweet button will not work on the SWF or HTML file due to the security of ones SWF settings. The Tweet button will however work on files uploaded to the internet or directly in the FLA.

You can test this on an internet uploaded version here:
http://www.newgrounds.com/dump/item/fd0ee4a166a9a3018e4c096b3744a3b6

Working Processes: Finalising the Game - Scripting the narration sound

I imported the soundclip I exported for testing purposes

For the narration, I decided to use a different SoundChannel and SoundTransform.

I added a script similar to that of the music, to add the sound effect.

I wanted the sound to play if the door was locked.

Here is the code I used originally:

if(!doorUnlocked){
        trace("Door is jammed shut");
        narrateChannel=narrateItsLocked.play(0,0,narrateTrans);
}


This script was placed inside the button of the door.
The problem with the script was that every time the door was clicked the sound would play on top of itself.
I needed a way so that this would not happen.

At first I tried:

if(narrateChannel!=narrateItsLocked){
narrateChannel=whatsThat.play(0,0,narrateTrans);
}


This was a good idea but it did not work.
I noticed that the channel would be null (hasn't been set to any sound) until a sound was played. After it's played the sound it was no longer set to null. Knowing this I tried the following script:

if(!narrateChannel){
Channel=narrateItsLocked.play(0,0,narrateTrans);
} else if (narrateChannel){
Channel=null;
}


This worked... but it wasn't to the extent I wanted.

My script made it so that it would only play once null. If it wasn't null, then it would make it null.
By doing so, it added a delay so that the script would only play the sound every other time you press it. Which meant that the sound would still overlap, it would take two clicks instead of one.

I then searched through the internet to find a script which acknowledge when the sound would stop playing. This was known as SOUND_COMPLETE.

I used the following script:

if(!narrateChannel){
    trace("1 narrateChannel "+narrateChannel);
    narrateChannel=narrateItsLocked.play(0,0,narrateTrans);
    trace("2 narrateChannel"+narrateChannel);
}

 narrateChannel.addEventListener(Event.SOUND_COMPLETE,onSoundChannelSoundComplete);
function onSoundChannelSoundComplete(e:Event):void{
    trace("done");
    narrateChannel=null;
}

This caused the following error:
Cannot access a property or method of a null object reference.

This meant that the script couldn't find when the sound was complete because it was on null.
I then adjusted the placement of the eventlistener, so it would not search for it straight away, but instead when the button was pressed.

My script now looked like this:

if(!narrateChannel){
            trace("1 narrateChannel "+narrateChannel);
            narrateChannel=narrateItsLocked.play(0,0,narrateTrans);
            trace("2 narrateChannel"+narrateChannel);
       narrateChannel.addEventListener(Event.SOUND_COMPLETE,onSoundChannelSoundComplete);
}

function onSoundChannelSoundComplete(e:Event):void{
    trace("done");
    narrateChannel=null;
}

This way the eventListener would be played only after the channel had been set.

The script worked perfectly.

I used these to help me add the sounds:
 http://www.trainingtutorials101.com/2010/01/adjusting-volume-in-flash-actionscript.html
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play%28%29

Working Processes: Finalising the Game - Recording the narration

Using the script I created here, I recorded myself in the software audacity saying the lines.
As there were a lot of white noise I had to remove it.
Here is the processes I went though.

1) Recorded the narration for the whole script so far.


2) Recorded white noise without speaking.


3) Selected the white noise and used it as a noise profile in the Noise Removal option

4) Selected the narration and applied the noise profile it from the Noise Removal option

5) Here was the results.

With that done, I then selected a line snippet and exported it as an MP3. I will first use this sound snippet for testing purposes before exporting the rest.

Thursday, 24 April 2014

Working Processes: Finalising the Game - Adding vending arrow, Fixing the timer

I realised that it may not be obvious to all users straight away that they can click the bottom of the vending machine to get to the dispenser. To make it more noticable, instead of adding an arrow which is always visible. I changed the over state of the button at the bottom of the vending machine so that an arrow will appear if the users mouse is over the button [at the bottom of the vending machine].




Whilst getting the music to work, and note overlap itself once the user goes back to the menu, I discovered a glitch.

The timer which I have put in place goes faster the more times you visit the menu. The reason for this is that the fl_SecondsElapsed++; is called once again.

To fix this issue, I created a boolean and inserted the Timer and EventListener inside it's if(statement)

 I used the following code:

if (!timerSet) {
    var fl_TimerInstance:Timer=new Timer(1000,3000);
    fl_TimerInstance.addEventListener(TimerEvent.TIMER, fl_TimerHandler);
    timerSet=true;
}


With this, the timer would now only be called once if it's on false. After the timer is called the boolean is set to true and now it will no longer recall the timer.

Working Processes: Finalising the Game - Adding the music

Instead of adding the music through the timeline properties, I instead done it through code.
This way, I would be able to adjust the volume of the music more easily as I feel that once I add the narration or sound effects, the music may be too loud to hear the rest.

The first thing I did was create import the video and give it a class name of soundTrack. With this I was able to add a SoundTransform for the volume and give the soundTrack a channel

Here is the code I used:

var letItGoShort:Sound = new soundTrack();
var trans:SoundTransform = new SoundTransform(0.5, 0);
var channel:SoundChannel;

 I then created a boolean called musicPlaying and set it to false

I then used the following script:

if(!musicPlaying){
    channel = letItGoShort.play(0, 1000 , trans);
    musicPlaying=true;
}


This script made it so that the music would only play if the boolean is set on false. By doing this I would avoid the music playing on top of itself once I revisit that frame.

The first 0 shows the start time, whilst the 1000 represents how many times the song will be repeated.

Working Processes: Finalising the Game - Editing the game from Supervisors feedback.

I managed to fix all of the things Daniel had mentioned in our tutorial from Yesterday.

The first thing I fixed was the back button.

At first, I thought it would be a good idea to merely go into the button, and change it's HIT state increasing the area of which the button can be clicked on. I added long rectangles on either side of the Flash and tested the game.

I realised that this would not work since the back button disappears if the users mouse is not at the bottom of the screen. Meaning that the additional hitstate would only be clickable once the users mouse is at the bottom.

In order to impliment the side back buttons which my supervisor stated would be a good idea. I created a new button and called the instance "backSide_btns". With this, instead of typing out a new function for this button or even copying and pasting the function from the previous button. I merely reused the exact same event listener to the new button and applied it to all the places accordingly.

back_btn.addEventListener(MouseEvent.CLICK,backtoMainListener);
backSide_btns.addEventListener(MouseEvent.CLICK,backtoMainListener);

The next part I modified was the pictures, I decreased the saturation of the picture frames so that they would suit the pastel colour look I was going for. I then traced over 2 of the portraits and coloured them in. I took a screen capture of this and sent it to my Supervisor Daniel so that he could see the results before I proceeded with the others.


He instantly replied and stated that they were looking much better and suiting the games appearance much more. Due to this I continued to transform the others.


Then I modified the inventory, instead of having it so that a message appeared stating inventory as the bottom. I changed it so that there would be a button at the bottom to indicate that there was something there. This way it would be much more noticeable for the users playing the game.

I then changed the code which affected the display of the inventory

if (mouseY <450) {
        menu_btn.visible=false;
        bottomBar.visible=false;
        inventory_btn.visible=true;
        if (currentFrameLabel!="viewMain") {
            back_btn.visible=false;
        }
}

So whenever the bottomBar (inventory) would disppear, the inventory_btn would appear and visa versa.

Finally, I went onto the colouring of the screen. Here are two screen captures of the difference in colours for the screen.

Before


After

I then went onto changing the appearance of the password on the note.

I rotated the curve of the "r" so that it was closer together and easier to distinguish from a "v".

Before
 After
Overall, I have very happy with the results obtained from my supervisors feedback!

Wednesday, 23 April 2014

Supervisor Tutorial 8: Inventory indication, back button additions, changes to pictures, and computer screen.

Today I had my file tutorial with my supervisor.
It was the first time he had seen my work since the prior to the Easter Holidays.

Daniel played through the game. To save time, I gave him tips on how to go about completing the game.

After he played through it, he suggested many things which I should change.

Daniel stated the following things:

Problem Solve
"Inventory at bottom" - displayed too fast Choose a different method to indicate inventory
Back button - does not feel natural Have alternative methods to go back (clicking on side of screen)
Change pictures from frames - too realistic Trace over them with the pen tool
Change colour of picture frames - doesn't fit with pastel theme Find appropriate colours
Screen's blue doesn't fit colour theme Find a pastel blue
The password r looks like a v Modify text


As well as the pictures in the picture frames looking too realistic in comparison to the game, Daniel also stated that three of the people in the picture frames are of celebrities as this is a bad thing as it takes you away from the experience. As this is the case, I -as mentioned above- will be tracing over those people and they will in turn be not only suit the rest of the games aesthetics but also won't resemble the celebrities they once did.

Daniel also stated that I should be careful with music choice. Once I showed him the music I had thought about using, he stated that he thought that the music suited the piece very well.

As I plan to finish this before Monday, as I would like to hand it in a day early [in case transport is bad], I will need to complete the fixes and add narration before Sunday ends.