yea, but the problem is that if someone does run it at 29 frames a second then there'll be a big problem.
Printable View
yea, but the problem is that if someone does run it at 29 frames a second then there'll be a big problem.
aquaCorpse, let me clear your mind :)
Normaly, when you've made a game, set it's fps to 25 in Flash, and run it iexplorer; it'll usually run at 22 fps. This is because some issues that the Flashplayer has with browsers, I won't go into too much detail there ;)
Anywayz, the loss of 3 fps isn't too bad, but it can still bother perfectionists who realy want a steady fps (or some games just require it).
Now PerciPea came with the wonderfull idea, of actually having your fps to run at a steady 25 when you want it too. However, this appeared not to be working at all, because it'll still have the 3 fps drop we were trying to get rid off.
That's the whole story, basicly :)
wmode = transparent will make it run in IE without any drops in frame rate.
Yeah! How does that whole wmode thing work? What is it for, what does it change, and why does it help with getting a steady fps?
whats wmode anyways?
wmode means Window Mode. Under the "publish" settings for your FLA file, go to the HTML tab and change the "Window" parameter to "Transparent". When you publish your SWF and view it in that HTML file, you'll notice that it runs pretty much as smoothly as it would when not in a web browser. I use transparent windows on my website when users view my movies, games, and experiments, because I don't want the public to view something slower than I intended. It really does help. There's a few gripes, though.
Certain coding on the page itself (frames, javascript, etc) may interfere with the movie clip. For example, my game, Gingerbread Run, at pnflashgames.com, ran pretty slow compared to what I compiled it at. I requested that the webmaster change the wmode to be transparent. To my surprise, he did (Leason is a great guy), but he had to soon change it back because pressing spacebar in the game would cause the window to scroll down.
However, that's a good thing, since it forced me to learn some of the ways of optimization. Yes, the sticky at the top of this forum works wonders (although it would be nice if all of the hard facts were editted into the first post, so newbies wouldn't have to read through several hundred posts to find them all).... I digress.
In short, Wmode transparent creates the swf on top of the html file, allowing it to run independent from the browser, if I remember correctly. That's why running two html files with transparent wmode's have a bigger hit on the cpu than having two regular wmodes.
Okay, done rambling.
- OneMrBean
Yes, you may have to adjust your onKeyPress-es in some situations. And wmode will screw with Firefox, so don't use it in embed tags. Firefox is lame when it comes to flash anyway and nothing really helps there.
for the wmode, it does not really need to be in transparent to let it run in the desire fps,
just put it in opaque or any other mode will do as well.
but if u use wmode parameter, then ur game will not accept keyboard press event in Firefox. i had ask this question on this forum how to fix this problem, but seems that this is a bug
ah i see that for clearing my mind SaphuA one might say enlightened ;)
For reference, all the code above does is burn CPU processor time in an attempt to slow flash down. It's called a "spin loop" when you do it accidentally. Flash doesn't provide the ability to "wait" or "sleep" like other langauges so there is no way to slow it down directly. Additionally, it's very memory intensive as its creating new objects for every iteration.
A better solution for true frame independence is to make your animation time based rather then frame based and then you can run at any framerate you want. Electrotank has started to do this for all our multiplayer games. Its a bit more work up front but it makes the game scale framerates dynamically. Additionally, it's VERY helpful for synchronizing remote computers. You can even do some tricky things like update certain aspects of the display less often to improve performance. Dynamically removing frame detail on the fly.
Any chance of elaborating on this some more webgeek?
Or just point me in the vicinity of some tutorials or something, ive heard about this before but I dont get how you achieve it and I havent found anything about on it.
Ive got this diablo type game im dying to make, I have the main engine in place but I want more enemies on screen damn it, I can get it to run with 10 on screen, but im looking for more like 25.
Thanks.
instead of doing
code:
this.onEnterFrame = function(){
//everything you want to do
}
you do
code:
fps=25;
function frame() {
//everything you want to do
}
setInterval( frame, 1000/fps );
Close, but not quite ihoss. The point isn't to try and run at a set interval (thats really all frames are), its more to make it so the code doesnt care about the interval, it just updates the position based on however long it's been. I've gone ahead and posted a new thread with some examples 'cause a few people asked me about this...
http://www.flashkit.com/board/showthread.php?t=639640
I got 25 with limit and 93 without.
OMG! YAY!.. I have always had that problem with all my Flash game parody movies, and with my kung fu game. The speed I want the movies to run in is 100% when playing it from the standalone flash player, but always much slower in IE, so what I have ALWAYS done is having a silent streaming sound in the back. Using a streaming sound in the back makes everything run in the exact same speed in IE as in the flashplayer. However, the downside of doing this is that if someone has a slow computer, the movies/games will be very jumpy (not fun to watch/play), but I had no choise.
Now when I'm working on my Moonstone project, I had the same problem, SO... I changed the wmode and it runs perfect in IE :P. Big thanks MikeMD.
Game with wmode: Link
Game without wmode: Link
This is a good idea for all flash movies, It's indeed very wise to make your fps independant from the Player's FPS.. But what you are doing is called a 'busy wait', which will hog up all CPU.. Read this post (not by me), also online: :
Quote:
Originally Posted by Troy Gilbert
You do know you just dug up a 7 year old thread?
Quote:
Originally Posted by SaphuA
Google made me do it ^^.
Not even 3 :)Quote:
Originally Posted by SaphuA
I presume SaphuA was judging by PercyPea's join date. :)