Babaloo
02-12-2007, 03:35 AM
hey!
I'm quite new to coding and actionscript, so please forgive me for the basic questions.
I'm working on a flash game, single player or (optional) two players, turn-based. Basically the game repeats itself, all i need is to restart the engine, the time counter and keep a tab on each players score.
I started with an initial function that sets game play time and number of turns. Inside that function I placed the counter. When time's out I add to the number of turns.
I can't figure how to restart the game for the 2nd optional player and store its data.
all code is in frame 1
setup = function ()
{
score = 0;
score_txt.text = score;
time = 45;
t = 0;
doCounter = function()
{
time--;
if (time == 0)
{ bgscroller.removeMovieClip();
clearInterval(countID);
t=t++;
}
}
countID = setInterval(doCounter, 1000);
};
// end setup
// turns control
turns = function()
{ if (levels * numPlayer <= numPlayer)
{
trace("Players: "+numPlayer);
}
}
// scrolling control
bgScrolling = function()
{
_root.attachMovie("bgscroll","bgscroller",10);
bgscroller.onEnterFrame = function()
{
if(this._x <= -550)
{
this._x=0;
}
this._x-=5;
};
};
// grphx
_root.attachMovie("splash","splashscreen",10);
splashscreen.attachMovie("playr1","playr1",10);
splashscreen.playr1._x = 400;
splashscreen.playr1._y = 040;
splashscreen.attachMovie("playrVS","playrVS",splashscreen.getNextHighestDepth());
splashscreen.playrVS._x = 460;
splashscreen.playrVS._y = 120;
numPlayer = new Object();
splashscreen.playr1.onRelease = function ()
{
numPlayer = 1;
playrBtn();
}
splashscreen.playrVS.onRelease = function ()
{
numPlayer = 2;
playrBtn();
}
//start button, game play, remove splash
playrBtn = function()
{
_root.attachMovie("start","start",99);
start._x = 400;
start._y =300;
start.onRelease = function ()
{
this.removeMovieClip();
splashscreen.removeMovieClip();
setup();
bgScrolling();
turns();
}
}
I'm quite new to coding and actionscript, so please forgive me for the basic questions.
I'm working on a flash game, single player or (optional) two players, turn-based. Basically the game repeats itself, all i need is to restart the engine, the time counter and keep a tab on each players score.
I started with an initial function that sets game play time and number of turns. Inside that function I placed the counter. When time's out I add to the number of turns.
I can't figure how to restart the game for the 2nd optional player and store its data.
all code is in frame 1
setup = function ()
{
score = 0;
score_txt.text = score;
time = 45;
t = 0;
doCounter = function()
{
time--;
if (time == 0)
{ bgscroller.removeMovieClip();
clearInterval(countID);
t=t++;
}
}
countID = setInterval(doCounter, 1000);
};
// end setup
// turns control
turns = function()
{ if (levels * numPlayer <= numPlayer)
{
trace("Players: "+numPlayer);
}
}
// scrolling control
bgScrolling = function()
{
_root.attachMovie("bgscroll","bgscroller",10);
bgscroller.onEnterFrame = function()
{
if(this._x <= -550)
{
this._x=0;
}
this._x-=5;
};
};
// grphx
_root.attachMovie("splash","splashscreen",10);
splashscreen.attachMovie("playr1","playr1",10);
splashscreen.playr1._x = 400;
splashscreen.playr1._y = 040;
splashscreen.attachMovie("playrVS","playrVS",splashscreen.getNextHighestDepth());
splashscreen.playrVS._x = 460;
splashscreen.playrVS._y = 120;
numPlayer = new Object();
splashscreen.playr1.onRelease = function ()
{
numPlayer = 1;
playrBtn();
}
splashscreen.playrVS.onRelease = function ()
{
numPlayer = 2;
playrBtn();
}
//start button, game play, remove splash
playrBtn = function()
{
_root.attachMovie("start","start",99);
start._x = 400;
start._y =300;
start.onRelease = function ()
{
this.removeMovieClip();
splashscreen.removeMovieClip();
setup();
bgScrolling();
turns();
}
}