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.

No comments:

Post a Comment