-
whats wrong with my interval...
Anyone got any idea why this :
Code:
MoveBalls = setInterval(moveBalls,5)
speed = 2
function moveBalls(){
for(i = 0 ; i<count;i++){moveClip(BoS[i],speed)}
if(BoS[BoS.length-1].myIndex >= 64){newBall()}
}
would have a weird variable speed in this SWF(make sure you dont shoot the ball cause right now it doesnt work quite right...)
[/url]http://abs.gprime.net/showflash.php?name=square_spiral&w=700&h=700[/url] <---SWF cut and paste...for somereason it wont link
just watch the pattern and how it moves...it goes fast then slows down
BTW myIndex is a variable that stores where the object is along an Array of points that creat the path for the ball to follow
(see below for ball path movement code)
Code:
function setPath(){
for (i = 0 ; i < 10000; i++){
var moving = null
if(lead.x < xBounds.right && lead.y == yBounds.top ){moving = "right";lead.x++}//move right
else if (lead.y < yBounds.bottom&& lead.x == xBounds.right){moving = "down";lead.y++} //move down
else if (lead.x > xBounds.left && lead.y == yBounds.bottom){moving = "left";lead.x--} //move left
else if (lead.y > yBounds.top && lead.x == xBounds.left){moving = "up";lead.y--}
tempPoint ={x:lead.x,y:lead.y}
if(moving=="up"){
distance = Math.sqrt(Math.pow((tempPoint.y - yBounds.top),2))
if(distance < 70){yBounds.top = tempPoint.y}
}else if(moving == "down"){
distance = Math.sqrt(Math.pow((tempPoint.y - yBounds.bottom),2))
if(distance < 70){yBounds.bottom = tempPoint.y}
}else if(moving == "left"){
distance = Math.sqrt(Math.pow((tempPoint.x - xBounds.left),2))
if(distance < 70){xBounds.left = tempPoint.x}
}else if(moving == "right"){
distance = Math.sqrt(Math.pow((tempPoint.x - xBounds.right),2))
if(distance < 70){xBounds.right = tempPoint.x}
}
controlArray.push(tempPoint)
}
//for(i = 0 ;i < controlArray.length;i++){trace(controlArray[i].x+" , "+controlArray[i].y)}
}
(I dunno maybe im just imagining it but it seemslike it slows down and speeds up on its own....im advancing it a static ammount and i thought my path was normalized...but hmmm...maybe someone can help me with my setpath function so the stored points are evenly spaced(I have about 7000 ish points in the array
Last edited by joran420; 05-05-2006 at 02:16 AM.
-
Registered User
hi,
The link you provide doesn't seem to work.
The script seems to be a bit processor intensive, with setInterval(), Math operations, and arrays... If you have many movie clips...
Could it be that that's slowing the player?
-
The link should work(it works for me when i cut and paste)...It just takes some time to load...there are at maximum about 400 target balls on screen...Im sure thats prolly having an effect...but i cant think of any beter way to do it (my game is basically a zuma clone and theres alot of math to be done for it...I cant see anyway around that)
If anyone has a better idea to make it less proccessor intensive please let me know
-
Registered User
Yes, the link's working now.
It's a lot of stuff for the Flash Player. It gets my processor at 100%.
Are you publishing for FP8? (using Flash 8?)
Maybe cacheAsBitmap helps in this case...
-
Sweet thanks man Im at work atm but ill give it a go when i get home...thanks alot
-
catchAsBitmap didnt seem to help at all
anyother ideas on why it would go fast then slow then fast again...
or anyideas on how i can avoid that problem?
-
I been thinking about it and id guess is that the slowdown is probably being caused by the growing count in the for loop (it takes longer to run through the for loop the more balls that are on screen)
is the only fix to put the movement code in the on enter event handle of the clip?
[edit] putting it in the on enterframe does work but i would rather loop it...but it seems like all i can do is put it in the onEnterFrame :/ oh well it works
Last edited by joran420; 05-07-2006 at 03:11 PM.
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
|