-
not'n' wrong with hat'n' sushi
[F8] Am I missing a piece of this code?
Here is my current script: (This is the area of my script where I think I am missing something.)
//these functions decide who won
function youWin() {
if (myScore>=10) {
this.gotoAndPlay ("winningend");
}
}
function youLose() {
if (dangerScore>=10) {
this.gotoAndPlay("loosingend");
}
}
stop();
On the winning end screen and loosing end this is my code:
//this stops it from advancing
stop();
//This is the music to end the game
music_loop.stop();
music_loop.attachSound("endingMusic.wav");
music_loop.start(0,999);
If anyone can fill me in what I'm missing it would be greatly appreciated. Or if I need to look at a different area of my code or if I am doing it assbackward all together. ThanksaBunxh!!!
-
FK'n_dog
at what point in your project are you calling these functions ?
couldn't you just have one score variable and use it at project-end-point
ie..you accumulate a score of 50 - myScore=50;
at end-point - checkScore(myScore);
function checkScore(num){
if (num>=10) {
gotoAndPlay ("winningend");
} else {
gotoAndPlay ("loosingend");
}
};
any help ??
-
not'n' wrong with hat'n' sushi
I am very new to actionscript and I guess I'd like to call myself a text book actionscripter. I only know a few ways to write code so if my code seems retarded this is the reason why
This is my code that is running my game
//This is the music for level one music
music_loop.stop();
music_loop.attachSound("levelOneMusic.wav");
music_loop.start(0,999);
//initial variables to set toucan and the coconut
xScale = _parent.bird_mc._xscale;
var bulletPosFlag:Number = 0;
var xSpeed:Number = 10;
var toucan:MovieClip = bird_mc;
var bullet:MovieClip = bullet_mc;
var maxTime:Number = 30; //seconds
//-----------------------------------------------------------------------------
//the variables bellow control the initial score for workers and toucan
//everytime a worker scapes scores a point agains toucan
var dangerScore:Number = 0;
var myScore:Number = 0;
//----------------------------------------------------------------------------
//controlling toucan
toucan.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
this.play();
this._xscale = xScale;
loopLeft();
} else if (Key.isDown(Key.RIGHT)) {
this.play();
this._xscale = -xScale;
loopRight();
} else if (!Key.isDown()) {
this.gotoAndStop(1);
}
};
var startTime:Number = getTimer()/1000;
this.onEnterFrame = function (){
fireBullet();
youWin();
youLose();
//time countdown
var timeNow:Number = getTimer()/1000;
var count:Number = timeNow - startTime;
timeLimit = maxTime - Math.round(count);
if(count >= maxTime){
dangerScore = 1000;
}
}
//---------------------------------------------------------------------------
//This function controls the flight upwards of the bullet
//the “-20” value indicates how fast
//the bulletPosFlag resets the bullet back to toucan or lets it fly!
//
function fireBullet() {
if (bulletPosFlag == 1) {
if (bullet._y>=-10) {
bullet._y -= 20;
} else {
bulletPosFlag = 0;
}
}else{
bullet._x = toucan._x +70;
bullet._y = toucan._y;
}
}
//----------------------------------------------------------------------
//these functions make toucan move left and right
//
//set the speed for the bird
var speed:Number = 20;
//capture the onEnterFrame event of the bird_mc movie clip
bird_mc.onEnterFrame = function() {
//move horizontally if the RIGHT or LEFT arrow keys are pressed
if (Key.isDown(Key.RIGHT)&& bird_mc._x < 590) {
this._x = this._x + speed;
} else if (Key.isDown(Key.LEFT)&& bird_mc._x > 115) {
this._x = this._x - speed;
}
};
//----------------------------------------------------------------------
//these functions decide who won…the workers or toucan
//everytime a worker scapes it will score a point
//every kill you score points
//
function youWin() {
if (myScore>=10) {
this.gotoAndPlay ("winningend");
}
}
function youLose() {
if (dangerScore>=10) {
this.gotoAndPlay("loosingend");
}
}
stop();
-
not'n' wrong with hat'n' sushi
There is a score for how many workers you hit. If you hit 10 workers you win, but if you hit 10 birds you loose. The only problem is the game plays fine until it goes to the screen where you win or loose. The music won't play properly and its properly linked, and it is not stopping. It makes a horrible sound like the music is looping over and over again like in one frame, and then after a few seconds it will advance to the loosing screen even though there is a stop on each one so I don't understand why its not stopping.
-
FK'n_dog
your problem is being caused here -
this.onEnterFrame = function (){
......
youWin();
youLose();
....
}
this is constantly calling the functions at the FPS of the movie as
the onEnterFrame is not being stopped, so try stopping it by
ending the onEnterFrame in your target end frames
on the frame with label - winningend
this.onEnterFrame = null;
on the frame with label - loosingend
this.onEnterFrame = null;
hth ??
-
not'n' wrong with hat'n' sushi
Thanks a bunch, I will give this a try and see if it works.
-
not'n' wrong with hat'n' sushi
You are a beautiful creatue of smartness! HAHA Thanks a whole bunch. I knew it had to be something to do with code. I had that pinned down at least. You're assistance was most appreciated : )
-
FK'n_dog
you're welcome
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|