PDA

View Full Version : [AS2] Problems With Pausing and Resuming Game and Watch Game.


chickenwing
04-16-2009, 03:37 PM
Good Day I have a flash game assignment. and i just learnt flash in the past few weeks.

The game is a Bell Boy game where you have to clear the Bags of the counters to the rooms(which are the waving hands)

and at the same time avoid the pails of water.

i have managed to script everything except being able to resume after getting losing a life.

there are instances where they work and times where they don't i have look at the script many times and i am very lost.

Looking for some guidance.

Thank you very much.


the link to the file is here (http://www.filehosting.org/file/details/23127/006_Bellboy_rush_with_obstacle.fla)

chickenwing
04-16-2009, 03:38 PM
link here too i think (http://www.filehosting.org/file/details/23127/hawz9ExwCTW2mHb9/006_Bellboy_rush_with_obstacle.fla)

Billy T
04-17-2009, 10:30 AM
I didn't want to give my email address to the file storage website but I'm guessing your using setInterval to move stuff around. To pause everything, you need to clear all those intervals

function pauseGame(){
clearInterval(someID);
clearInterval(someOtherID);
clearInterval(yetAnotherID);
}

If anything doesn't stop when the pauseGame function is called, you need to find the ID of the applicable setInterval and add it to the function.

Your resume game will just be the reverse of the pauseGame

function resumeGame(){
someID=setInterval(someFunction,someSpeed);
//etc
}

cheers

chickenwing
04-17-2009, 01:10 PM
http://www.yousendit.com/transfer.php?action=download&ufid=WnBSSlJ3Mm10d0YzZUE9PQhttp://www.yousendit.com/transfer.php?action=download&ufid=WnBSSlJ3Mm10d0YzZUE9PQ

I have added anothe rlink above

hi billy i have tried that but i still am having problems do hope someone can help thank you

Billy T
04-17-2009, 01:42 PM
you need to be more specific. What exactly do you want to happen and when? And where is the relevant code in your file?

chickenwing
04-17-2009, 02:13 PM
Right now if you walk pass the spilled pails, and when that happens the char_mc will flash and you will lose a life.

the code for the pause and resume are in line 407 of the main timeline.

and when the bags over flow at the bottom, i will lose a life too.

the flashing of the character has been coded in the char _mc itself.

The problem is that my friends and I have followed the 24 video tutorials and we have used the set intervals in the pause and resume. But there are Bugs in our flash files, we are Noobs that are learning flash so when we proof read each others files we do have a problem.

Anyway Thanks Billy, you are the only person who has replied to me after my lecturer has recommended me this Forum.
Thanks
Regards

Billy T
04-17-2009, 02:47 PM
I'm still clear on what your problem is. You have said what it is doing - but what do you want it to do?

You should also disable the keyboard in your pauseGame function

Key.removeListener(keyboardListener);


and add the listener back again in your resumeGame function.

I noticed when a bucket overflows or something you are calling loseLife and pauseGame - you just need to call loseLife as the pauseGame function is called inside the loseLife function.

In your lose life function you should

adjust lives
pause game
flash char
start a set interval that will reset the game after a few seconds

The snip and chu example provided in class shows exactly how to do all this.

Anyway, if you still need help you really need to be more clear about exactly what you want to happen.

cheers

chickenwing
04-17-2009, 04:14 PM
You have seen the flash file.
when the character gets hit by the pails above the pause and resume game runs smoothly.

But when he hits the pails at the bottom he does not flash and the game does not resume.

the caracter has been coded the same way both at the top and bottom but they react differently.

and when the bags overload at the bottom of the screen they do not clear after the game has paused even though i have a clear Interval in my script.

I have attached Pictures to help my explanation

Billy T
04-18-2009, 07:46 AM
firstly, I just tested your movie, staying in the starting position and waited for a spill bottom right. When it came, I moved right and it all seemed to work ok. Flashed and paused and restarted anyway.


clearInterval(bagID); will not make the bag movieclip reset. You probably need to also say

casetable_mc.gotoAndStop(1);

You should make a resetGame function to take care of all of those sort of things.

The location of your adjust life code is ok, but this would often not get reached because you had not disabled the keyboard when the game was paused. Make sure you add that - mentioned it in an earlier post.

If you ask any more questions make sure you upload an updated fla file to work from.

cheers