Hi ya folks I'm new, and looking for help.
I'm struggling with a bit of an assignment where I'm supposed to be writing a coin flipping game of sorts.
Everytime you click (anywhere in the movie, no where special) Heads or Tails appears randomly.
A tally is kept in textfields below the coin for how often heads and tails have appeared.
You have the ability to keep clicking until one of the tallys reaches 10 and the textfields are replaced with one saying either Heads or Tails has won.
I've linked to the finished example
I'm struggling with a bit of an assignment where I'm supposed to be writing a coin flipping game of sorts.
Everytime you click (anywhere in the movie, no where special) Heads or Tails appears randomly.
A tally is kept in textfields below the coin for how often heads and tails have appeared.
You have the ability to keep clicking until one of the tallys reaches 10 and the textfields are replaced with one saying either Heads or Tails has won.
I've linked to the finished example
My code so far:
onClipEvent (mouseDown) {
flipCoin();}
function flipCoin() {
var headCount:Number = 0;
var tailCount:Number = 0;
var i.Number = 0;
do {
i = random(2);
if (i == 1) {
headCount++;
gotoAndPlay(###);
//heads count shows incremented}
else {
tailCount++;
gotoAndPlay(###);
//tails count shows incremented};
playCoin = new Sound();
playCoin.attachSound("coinflip.wav");
playCoin.start();
} while ((headCount<10) || (tailCount<10));
onClipEvent (mouseDown) {
flipCoin();}
function flipCoin() {
var headCount:Number = 0;
var tailCount:Number = 0;
var i.Number = 0;
do {
i = random(2);
if (i == 1) {
headCount++;
gotoAndPlay(###);
//heads count shows incremented}
else {
tailCount++;
gotoAndPlay(###);
//tails count shows incremented};
playCoin = new Sound();
playCoin.attachSound("coinflip.wav");
playCoin.start();
} while ((headCount<10) || (tailCount<10));
And the Original Instructions:
This assignment is fairly easy, but you’ll need to remember a little of everything we’ve talked about so far: functions, variables, making random numbers, sounds, movie clips, and dynamic text fields.
* Download the FLA file and create a coin flip game
* FLA file has the graphics and sound in it
* Create a coin movie clip symbol.
* Make a coin flip function that is called when you click on the coin. You will not get credit if you don’t make your own function like we did in class on 2/15. It should make a “flip” sound and choose either “heads” or “tails”, increasing the tally for that side.
HINT: make the coin a movie clip and use the onClipEvent handler. Movie clips can have mouse handlers too!
* Create textfields to show the number of heads and tails flips.
* The first tally to 10 flips wins, and goes to a “win” frame!
This assignment is fairly easy, but you’ll need to remember a little of everything we’ve talked about so far: functions, variables, making random numbers, sounds, movie clips, and dynamic text fields.
* Download the FLA file and create a coin flip game
* FLA file has the graphics and sound in it
* Create a coin movie clip symbol.
* Make a coin flip function that is called when you click on the coin. You will not get credit if you don’t make your own function like we did in class on 2/15. It should make a “flip” sound and choose either “heads” or “tails”, increasing the tally for that side.
HINT: make the coin a movie clip and use the onClipEvent handler. Movie clips can have mouse handlers too!
* Create textfields to show the number of heads and tails flips.
* The first tally to 10 flips wins, and goes to a “win” frame!
