Sound is a vital part of a game, as it helps to bring the interactivity and gameplay to a new level. Without sound, it would loose alot of the charm. I added sound to my game with a few simple commands. First I had to import flash.sound and soundchannel. Without these, flash would not play the sound. The I created some Variables importing my sound from the flash file, and then set the sound to play.
In addition to background music I created a jump sound that would play each time he, of course, jump. This was done by entering sc2 = jumpSound.play(); in my jumpcode. The sc2 means that the sound will be played in sound channel 2, and will not overlap the background music.
Monday, 16 November 2009
Caze 8
in this case we had to create something called Arrays and Timers. We would have to lay out some objects, that would give us points, and we would use arrays for that task. what is good about arrays is that you can easily create many objects at the same time, and insert a command that these objects would respond to, instead of putting the objects out one at a time and insert manually a command to each of these.
In my game, I wanted to put out objects and gain more health, instead of gaining points. I formed the array objects as standard cakes, and also made a health icon top left corner. This icon scales itself and symbolises how much health the character has. the less health, the smaller icon.
To create the array I wrote a variable with :Array, and imported the icon from the fla file. I also added a new variable with with a :int , which would symbolise how much life I start with. In this case I used the number 30.
To remove the cakes when the character touched them I created a new function, where I wrote that if main chracter hitTestObject the cake, it would removeChild, thus remove the cake. by adding the a [s] at the end of Array, it would remove the cake my character hit.
For making the Healthicon, I created several movieclips with different size of the icon. I then imported them into Actionscript, and used a hpnumber variable(which was set to 30), and then used a changeanimation code to make the icon change if my hpnumber decreased. I coded that the hpnumber would decrease if my character hitTest the Bean, thus decreasing the hpnumber with "--".
I did not add a timer, as my game does not need it. But if I were to create it, I could add it with importing a timerEvent and a Timer, and then add a function that would control the timer.
In my game, I wanted to put out objects and gain more health, instead of gaining points. I formed the array objects as standard cakes, and also made a health icon top left corner. This icon scales itself and symbolises how much health the character has. the less health, the smaller icon.
To create the array I wrote a variable with :Array, and imported the icon from the fla file. I also added a new variable with with a :int , which would symbolise how much life I start with. In this case I used the number 30.
To remove the cakes when the character touched them I created a new function, where I wrote that if main chracter hitTestObject the cake, it would removeChild, thus remove the cake. by adding the a [s] at the end of Array, it would remove the cake my character hit.
For making the Healthicon, I created several movieclips with different size of the icon. I then imported them into Actionscript, and used a hpnumber variable(which was set to 30), and then used a changeanimation code to make the icon change if my hpnumber decreased. I coded that the hpnumber would decrease if my character hitTest the Bean, thus decreasing the hpnumber with "--".
I did not add a timer, as my game does not need it. But if I were to create it, I could add it with importing a timerEvent and a Timer, and then add a function that would control the timer.
Caze 7
This case was about creating an enemy that had some sort of AI. I created my enemy as a Bean Worker, as it would seem fitting to my gamestory. I created three different animations for him: Walkcycle, hitcycle and death.
The Beanworker was supposed to have enough AI to follow my character and hit him when my main character got too close. I did this by creating a new actionscript file containing information about the Beans walk direction to my main character. The speed and gravity on the Bean Worker was also added in this new actionscript file. I then named the .as file the same name as my exportname of my beanworker (BeanWorker), and when I import my character in my main actionscript file, it will also run this 2nd actionscript file.
I also got it playing the hitanimation by writing a hitTestObject. command. Now when my main character touches the enemy, my character will begin his hit-cycle.
The problems I detected was to activate my new actionscript file (BeanWorker.as) with my main file. I did not know that they had to have same name. After I found that out, I could begin clean my main actionscript file by cutting out coding of the beanworker to the new actionscript file.
The Beanworker was supposed to have enough AI to follow my character and hit him when my main character got too close. I did this by creating a new actionscript file containing information about the Beans walk direction to my main character. The speed and gravity on the Bean Worker was also added in this new actionscript file. I then named the .as file the same name as my exportname of my beanworker (BeanWorker), and when I import my character in my main actionscript file, it will also run this 2nd actionscript file.
I also got it playing the hitanimation by writing a hitTestObject. command. Now when my main character touches the enemy, my character will begin his hit-cycle.
The problems I detected was to activate my new actionscript file (BeanWorker.as) with my main file. I did not know that they had to have same name. After I found that out, I could begin clean my main actionscript file by cutting out coding of the beanworker to the new actionscript file.
Subscribe to:
Posts (Atom)