Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Speed problem..

Status
Not open for further replies.

BigBadDave

Programmer
May 31, 2001
1,069
EU
...Ok heres the deal,

I have a movieclip game that was ok when it was it's own movie, but now i have put it into a new movie, the problem is now it plays really slow. any ideas??

Regards

Big Dave

davidbyng@hotmail.com


** If I am wrong I am sorry, but i'm only trying to help!! **
 
I take it that the frame rate was the same in the original game?
 
yeah it was the same, and another thing when you get to the end of the game it plays fine, it just seems to play slow while its executing the game loop (eval() bit and so on) Regards

Big Dave

davidbyng@hotmail.com


** If I am wrong I am sorry, but i'm only trying to help!! **

 
Dave, I've had a quick look through your .fla and I can't see any major reason why it would run at different speeds because of the movie it's in - that's pretty weird.

The major load on the CPU seems to be the tweening within the MCs.

But I think I've found some ways to speed it up in general, it's just a cursory glance and I could be missing the point of what you were going for (if so I apologise in advance :) ) but these seem logical...

1) myrandom = Number(random(4))+1;
for (z=0; z<4; z++) {
foof = eval(&quot;_root.game.grinch&quot;+z);
if (myrandom == z) {
foof.play();
}
}


could be replaced by

myrandom = Number(random(4))+1;
foof=eval(&quot;_root.game.grinch&quot;+myRandom);
foof.play();


...which saves a few cycles.

2) onClipEvent (enterFrame) {
if (this, hittest(_root.game.grinch1)) {
_root.game.grinch1.grinch.gotoAndPlay(&quot;end&quot;);
_root.game.hits = _root.game.hits+1;
} else if (this, hittest(_root.game.grinch2)) {
_root.game.grinch2.grinch.gotoAndPlay(&quot;end&quot;);
_root.game.hits = _root.game.hits+1;
} else if (this, hittest(_root.game.grinch3)) {
_root.game.grinch3.grinch.gotoAndPlay(&quot;end&quot;);
_root.game.hits = _root.game.hits+1;
} else if (this, hittest(_root.game.grinch4)) {
_root.game.grinch4.grinch.game.gotoAndPlay(&quot;end&quot;);
_root.game.hits = _root.game.hits+1;
}
}


could be done with...

onClipEvent (enterFrame) {
for (i=1; i<5; i++) {
badGuy = eval(&quot;_root.game.grinch&quot;+i);
if (this.hitTest(badGuy)) {
badGuy.grinch.gotoAndPlay(&quot;end&quot;);
_root.game.hits++;
}
}
}


...which is cleaner (although not necessarily faster).

3) onClipEvent(load){
stop();
}


...doesn't actually do anything because clipEvents don't work with frames.

One major timesaving would be to run the snowball hitTests from the grinch that's currently running rather than from the ball - that way you're only testing for one thing being hit, not four (hitTests are pretty slow code).

Hope this helps. Nice idea by the way, wish I'd thought of it for our e-card...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top