Sound delays further and further
Hello!
I'm trying to make a flash dance game. You can see my current progress here:
http://www.reachground.se/spel/chris...dance2006.html
The problem is that the music, compared to the game, moves too fast. The further in the game you get, the earlier you have to press the arrow to hit it at the right time.
Here's my code:
Code:
//----------------------------------
// Dance Revoloshoon -----
// X12000 - Reachground.se -----
//----------------------------------
//***********************************
// GENERAL VARIABLES AND IMPORTS
//***********************************
//Load the snow clip
loadMovieNum("snow.swf", 15);
//Import the music
_root.attachMovie("weWishYou_mc", "Music", 200)
//Import the movie "Very Good"
_root.attachMovie("perfect_mc", "perfect", 100);
perfect._x = 300;
perfect._y = 250;
//********************************
// THE RED ARROWS AT THE BOTTOM
//********************************
var x = 150; //x startvalue of the arrows
//Imports the arrows and puts them in place
for (i = 1; i < 5; i++)
{
_root.attachMovie("arrowPosition_mc", "arrowPosition" + i, i);
var AP = eval ("arrowPosition" + i); // AP = The common name of the arrows
AP._y = 440; //The y-position of the arrows
AP._x = x; //The x-position of the arrows
x += 100; //x increases by 100 every loop
}
//The AP-arrow rotation
arrowPosition1._rotation = 270;
arrowPosition2._rotation = 180;
arrowPosition3._rotation = 0;
arrowPosition4._rotation = 90;
//*******************
// THE FALLING BALLS
//*******************
function createArrow(direct /*direction*/)
{
var depth = getNextHighestDepth();
_root.attachMovie("fallingArrow_mc", "fallingArrow" + depth, depth);
var the_fallingArrows = eval ("fallingArrow" + depth);
if(direct=="l")
{
var x = 150;
the_fallingArrows._rotation = 270;
}
else if(direct=="d")
{
var x = 250;
the_fallingArrows._rotation = 180;
}
else if(direct=="u")
{
var x = 350;
the_fallingArrows._rotation = 0;
}
else if(direct=="r")
{
var x = 450;
the_fallingArrows._rotation = 90;
}
the_fallingArrows._x = x; //sets the_fallingArrows x-values
the_fallingArrows._y = -45; //sets the_fallingArrows y-value
fallingArrowArray.push(the_fallingArrows);
}
var fallingArrowArray :Array = new Array();
//*******************************************
//OnEnterFrame - This is where it happens...
//*******************************************
var FallY = 10; //the_fallingArrows fall speed
var OutsideY = 650; //The y-value for when the arrows end up outside
var PerfectTopY = 460; //The perfect bonus, the y-value at the top
var PerfectBottomY = 420; //The perfect bonus, the y-value at the bottom
var timer = 49; //Sets the startvalue of the music-sync
onEnterFrame = function()
{
timer += 1;
#include "bana.as"
for( i in fallingArrowArray )
{
var the_fallingArrows = fallingArrowArray[i];
the_fallingArrows._y += FallY; // Makes the_fallingArrows starts to fall
if(the_fallingArrows._y >= OutsideY) // Removes the_fallingArrows when they end up outside the stage
removeMovieClip(the_fallingArrows);
//Checks if you press the right button
if (the_fallingArrows._y < PerfectTopY && the_fallingArrows._y > PerfectBottomY)
{
if (Key.isDown(Key.LEFT) && the_fallingArrows._x == 150)
{
fallingArrowArray.splice(i,1);
removeMovieClip(the_fallingArrows);
perfect.gotoAndPlay(2);
}
if (Key.isDown(Key.DOWN) && the_fallingArrows._x == 250)
{
fallingArrowArray.splice(i,1);
removeMovieClip(the_fallingArrows);
perfect.gotoAndPlay(2);
}
if (Key.isDown(Key.UP) && the_fallingArrows._x == 350)
{
fallingArrowArray.splice(i,1);
removeMovieClip(the_fallingArrows);
perfect.gotoAndPlay(2);
}
if (Key.isDown(Key.RIGHT) && the_fallingArrows._x == 450)
{
fallingArrowArray.splice(i,1);
removeMovieClip(the_fallingArrows);
perfect.gotoAndPlay(2);
}
}
}
}
Bana.as looks like this:
Code:
switch(timer)
{
//1
case 84:
createArrow("u");
break;
//2
case 110:
createArrow("u");
break;
//3
case 137:
createArrow("l");
break;
//4
case 164:
createArrow("l");
break;
...and so on.
Thanks for your help.
PS. I'm not that advanced in Actionscripting. I've done most of this myself but some (the Array for instance) is by the help of a friend. DS.