00:00
00:00
Newgrounds Background Image Theme

sa5678 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Pausing Function Help

1,110 Views | 4 Replies
New Topic Respond to this Topic

Pausing Function Help 2006-11-26 15:14:44


Hi y'all.

I started making a menu for my game today, and it is going well,and added with virtually problems, except one. When i activate my pause function, it cancels all my _root. onEnterFrames, it just stops them somehow. I used trace(); to bring up "EnterFrame" in the output panel, but as soon as i run the function, it stops.

Basically, the function (when called), makes a mC dynamically tween onto the stage, then when 'back to game' is pressed in teh menu, it retracts. That all works fine.

Anyway, here's the pause code, if anyone can tell why it's stopping my enter frame, please tell me. I also have code on a button so that when 'Insert' is pressed, it pauses.


function pauseMenu() {
if (!pauseComplete && mC._x<=-100) {
for (i=0; i<20; i++) {
_root["Enemy3"+i].stop();
}
mC.swapDepths(getNextHighestDepth());
Cursor1.swapDepths(getNextHighestDepth());
Cursor2.swapDepths(getNextHighestDepth());
Cursor3.swapDepths(getNextHighestDepth());
_root.gamePaused = true;
clearInterval(_root.en3Int);
clearInterval(_root.en1Int);
pauseComplete = true;
trace("!gamePaused");
gamePaused = true;
var pauseMove:Tween = new Tween(mC, "_x", Elastic.easeOut, -263.4, 300, 2, true);
onEnterFrame = function () {
pauseDistance = 300-mC._x;
if (pauseDistance<0) {
pauseDistance *= -1;
}
var pauseBlur:BlurFilter = new BlurFilter(pauseDistance/6, 0, 1);
mC.filters = [pauseBlur];
};
}
if (pauseComplete && mC._x == 300) {
pauseComplete = false;
trace("gamePaused");
var pauseMove:Tween = new Tween(mC, "_x", Elastic.easeIn, 300, -263.4, 2, true);
onEnterFrame = function () {
pauseDistance = 300-mC._x;
if (pauseDistance<0) {
pauseDistance *= -1;
}
var pauseBlur:BlurFilter = new BlurFilter(pauseDistance/6, 0, 1);
mC.filters = [pauseBlur];
};
pauseMove.onMotionFinished = function() {
for (i=0; i<20; i++) {
_root["Enemy3"+i].play();
}
_root.gamePaused = false;
en1Int = setInterval(createEnemy1, (20-level)*300);
en3Int = setInterval(createEnemy3, (20-level)*400);
};
}
}


BBS Signature

Response to Pausing Function Help 2006-11-26 17:56:04


Anyone, please :(.


BBS Signature

Response to Pausing Function Help 2006-11-27 12:41:59


Sorry for bumping, but i really need a hand :(.


BBS Signature

Response to Pausing Function Help 2006-11-27 12:59:53


When you redefine your onEnterFrame = function() {, it doesnt add on to your previous, but actually replaces it. Is it possible you are accidentally replacing your onEnterFrame in this bit of code?

Also, think about doing something real simple, such as...

var paused:Boolean = false;

onEnterFrame = function() {
if(!paused) {
control();
backgrounds();
otherstuff();
}
}

Something as simple as that makes for an easy pause.


Hi there!

BBS Signature

Response to Pausing Function Help 2006-11-27 13:31:16


At 11/27/06 12:59 PM, jmtb02 wrote: Something as simple as that makes for an easy pause.

Yeah, i'll rewrite the function simply if noone can find any errors. But i'd rather keep this one, it looks good and helps me practice tweening through AS.

I don't think I've canceled my onEnterFrame or replaced it, but i'll double check, thanks :).

Anyone else have any ideas?

BBS Signature