hey, im pretty new with flash, but i have this game prototyping class im in and our first assignment is to create a simple breakout game in flash.
so everything works, all i need to do is add sound.
I was wondering if its possible to add sounds in hitTest’s, so when my ball hits the brick it will make a certian sound.
In my case, my bricks are animated vials of liquid. when you hit the brick once, the vial cracks, and when you hit it again it breaks open.
I want to have a 2 different sounds when it gets hit the first time (when it cracks) and the second time (when it breaks)
here is an example of the first hitTest in my brick when it cracks:
[/color] [color=Gray][color=Blue] if(this.hitTest(_root.aBall) && this.brickHit==0)
[color=Blue] _global.v_yDelta = _global.v_yDelta * -1;[/color] //makes my ball bounce off the
[color=Blue]gotoAndPlay(61);[/color]//tells it play the cracked vial animation (because now its cracked, you hit it once.)
if this isnt possible to do, or there is an easier way that would be helpfull. also, my code for my brick is a bit…sketchy if you will? Im pretty sure the way i coded it is one of the most messy ways possible and there is probably a more efficient way to do it. I’ll try to explain the best i can on how it works: (sorry for the long post)
I have two layers inside my brick’s timeline. my fps is set at 60, so i have each frame of animation stretched out to 10 frames each (except for when it breaks. those are a bit shorter.) So my animation plays through and when it hits frame 60, unless the brick was hit by the ball, it will loop back to frame one, indicating that it hasnt been hit once and it hasnt cracked yet. if it WAS hit by the ball, then it goes to and plays frame 61 which is the beginning of my cracked brick animation. when the cracked animation reaches frame 120, unless the brick was hit, it will go back and play frame 61. if it WAS then it goes to and plays frame 121, which is the beginning of my break animation, then it disapears, gives you points, and stops.
the code above is basically what the code looks like in every frame that it checks for the ball hitTest.
I hope that made sense, thanks to anyone who can help me out…this project is due friday!!! i appreciate any speedy comments/help/or anything