Nope. Not unless u have made your game fps dependant. Like run a piece of code every 4 frames. ie: Have a movie clip, inside that movie clip: Frame 1-3 = empty, frame 4 has the code like gotoandplay(1), then it will be running at 4fps, or when u want it go faster, change it to 3, that is make it run fast cuz it will be looping between frame 3 and 4. You just have to make the (1) a variable so u can change it in the game while it's running.
Btw,, didn't think while writing this.......... back to world of warcraft...
nah, I was talking about changing the actually fps cause in some games, you need to have a high frame-rate for it to run good, but then animating cutscenes and crap becomes a pain in the ass. Oh well, guess I can always double frame
Hmm....Iam guessing that setInterval() might do what you want. You can have the cutscene animation in a mc. In the first frame of the mc the code can be this:-
Code:
//animation's current frame
var currframe = 1;
function movemovie() {
this.gotoAndStop(currframe);
currframe++;
}
var intervalID;
// change the 1000 with the fps speed you like, 1000 means 1 second
intervalID = setInterval( movemovie, 1000 );
Code:
// on the last frame of the movie clip
clearInterval( intervalID );
Have'nt tried it, just outta my mind.
edit:syntax errors
Last edited by adit_ya_sharma; 07-07-2005 at 10:00 AM.
but this method isnt very acurate if you want to jump between higher frame rates, ie 20fps+
First thing is to set your flash movie to publish at the maximum frame rate you want anything to run at.
Ie, if you want the fastest parts of the game to run at 40fps, set your frame rate to that
Then, in a new layer that lasts the length of your flash movie, stick in a movieclip.
On the first frame of the movie clip, place this code:-
Code:
starttime = newDate()
onEnterFrame=function(){
var currtime=new Date()
var ttime=currtime-starttime
while(ttime<1000/DESIREDFRAMERATE){
var currtime = new Date()
var ttime=currtime-starttime
}
starttime=new Date()
}
Wher it has 'DESIREDFRAMERATE' simply change this to be the frame rate you want to make the movie at.
Apart from a few values in the high teens, this code will allow you to change the framerate of the movie to any fps from 1 to 12.
You will also be able to set the framerate faster, up to the 40 (or whatever you publish the movie at) but due to the way flash works, it wont be as accurate.
Ie, if you put in both 13 or 14 as the 'DESIREDFRAMERATE', the movie would run at the same speed.
15 and 16 are also the same. 17, 18 and 19 will give the same.
As you get higher, you will find more values give the same rate. 20-24 are the same, 25 - 33 are the same. If you tell flash to publish the movie at the maximum of 120fps, you'll find that settingthe 'DESIREDFRAMERATE' between 34 - 49 will be the same framerate, setting it to 50 - 99 same, 100-120 also the same.
The reason why you get less accurate changes as you try for higher frame rates, is because flash seems to have to take factors of 0.01 seconds to run the code on the 'onEnterFrame' bit.
To have a frame rate of 80fps, you'd need every frame to last for exactly 0.0125 seconds, but flash wont let that happen, so by putting in 80, you get it rounded up to the nearest 0.01. So each frame actually lasts 0.02 seconds, which means you get a 50fps movie.
anyhow, attached is a basic example using the code above.
The value on the left is editable, the value on the right shows how long the ball takes to bounce in milliseconds. The animation of the ball is 18 frames, so you can see that the time changes at intervals of 180ms per bounce. (0.01 seconds per frame).
The movie is published at 120fps.
A more practical method of the code can also be found in this GTA tech demo.
the game will either try to run at the maximum of 120fps (depending on the speed of your computer) or you can limit it to 25fps by clicking the white button on the left of the fps counter.
Like adit ya sharma said.. but I didnt explain it codewise or good, was lazy and was playing a game.... .... but set interval is the way to go.
nah, I was talking about changing the actually fps cause in some games, you need to have a high frame-rate for it to run good, but then animating cutscenes and crap becomes a pain in the ass. Oh well, guess I can always double frame
The actual frames of Flash cannot be changed, so the only way is to code your game in a certain way, like above adit told you.
but this method isnt very acurate if you want to jump between higher frame rates, ie 20fps+
First thing is to set your flash movie to publish at the maximum frame rate you want anything to run at.
Ie, if you want the fastest parts of the game to run at 40fps, set your frame rate to that
Then, in a new layer that lasts the length of your flash movie, stick in a movieclip.
On the first frame of the movie clip, place this code:-
Code:
starttime = newDate()
onEnterFrame=function(){
var currtime=new Date()
var ttime=currtime-starttime
while(ttime<1000/DESIREDFRAMERATE){
var currtime = new Date()
var ttime=currtime-starttime
}
starttime=new Date()
}
Wher it has 'DESIREDFRAMERATE' simply change this to be the frame rate you want to make the movie at.
Apart from a few values in the high teens, this code will allow you to change the framerate of the movie to any fps from 1 to 12.
You will also be able to set the framerate faster, up to the 40 (or whatever you publish the movie at) but due to the way flash works, it wont be as accurate.
Ie, if you put in both 13 or 14 as the 'DESIREDFRAMERATE', the movie would run at the same speed.
15 and 16 are also the same. 17, 18 and 19 will give the same.
As you get higher, you will find more values give the same rate. 20-24 are the same, 25 - 33 are the same. If you tell flash to publish the movie at the maximum of 120fps, you'll find that settingthe 'DESIREDFRAMERATE' between 34 - 49 will be the same framerate, setting it to 50 - 99 same, 100-120 also the same.
The reason why you get less accurate changes as you try for higher frame rates, is because flash seems to have to take factors of 0.01 seconds to run the code on the 'onEnterFrame' bit.
To have a frame rate of 80fps, you'd need every frame to last for exactly 0.0125 seconds, but flash wont let that happen, so by putting in 80, you get it rounded up to the nearest 0.01. So each frame actually lasts 0.02 seconds, which means you get a 50fps movie.
anyhow, attached is a basic example using the code above.
The value on the left is editable, the value on the right shows how long the ball takes to bounce in milliseconds. The animation of the ball is 18 frames, so you can see that the time changes at intervals of 180ms per bounce. (0.01 seconds per frame).
The movie is published at 120fps.
A more practical method of the code can also be found in this GTA tech demo.
the game will either try to run at the maximum of 120fps (depending on the speed of your computer) or you can limit it to 25fps by clicking the white button on the left of the fps counter.
thanks! Thats awsome. BTW, how did you get your gta game to have 3d buildings? Is there any way you can combine that with a mode7 engine?
In CS3 with AS3 this is as easy as changing the Stage.frameRate property. I'm using it as we speak and it works great. There are better ways though as describe above, but this does indeed change the running framerate of main timeline.
well I guess I meant rather the other one,- anyway to contribute a little bit too:
independent movement is the key anyway- just set your framerate to the maximum you want (dont overdo, 120 fps is the limit anyway) and write a tween function that returns you the value depending on what time it starts, ends and home much already elapsed.
If you use the tween class for example (works with flash player 7+) you can pass a var saying that it should be time dependent or frames but framewise it´s not always accurate as the performance can different.