Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1026170 Posts in 41128 Topics- by 32727 Members - Latest Member: JesseBurch14

July 24, 2014, 12:26:05 AM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Help! What causes Flash to lag?
Pages: [1]
Print
Author Topic: Help! What causes Flash to lag?  (Read 2508 times)
rayteoactive
Level 1
*



View Profile WWW Email
« on: April 12, 2010, 07:03:08 PM »

So... I'm a designer/artist, and I'm almost done with my new flash game - Galactic Commandos 2. Problem is - it's lagging. I always hire freelance programmers to work on my games, but we always end up with this lagging issue.

Anyone has any idea what might have cause it? I admit our graphic might be slightly intense, but I'm sure flash can definitely do better. I have heard the problem are usually with the script though I'm not sure in what sense. Definitely need the help here.

Anyway, you can try the game here...
http://tobesadventure.squarespace.com/storage/galactic2.swf

note that it is WIP, so there's no tutorial message, and you might not reach certain areas.Let me know if it lags for you though. The controls displayed are also incorrect. It should be arrows to move, ctrl, shift and / to swtich, attack, and use ability.
« Last Edit: April 12, 2010, 07:10:16 PM by rayteoactive » Logged

Bite Bite Bite Bitejacker!
http://secretbase.com.sg/
John Nesky
Level 10
*****


aka shaktool


View Profile WWW
« Reply #1 on: April 12, 2010, 07:15:22 PM »

When I expand the window, the game scales up with it. When I run so that the background is scrolling while the window is large, the game slows down. If I shrink the window it runs better. Alternatively, it also runs better when the background is not scrolling. I know I've seen at least one Flash game solve this by scrolling in chunks (like Another World) instead of scrolling smoothly so that they didn't need to do fullscreen redraws all the time...

The background is large bitmap(s), and Flash draws bitmaps faster if the scale of the bitmap is the same as the screen pixels. Maybe try disabling scaling?
Logged
grapefrukt
Level 1
*



View Profile WWW Email
« Reply #2 on: April 12, 2010, 10:10:27 PM »

I agree on the scaling, make sure your big bitmaps are 1:1 that'll give you a nice boost.

If your graphics have a lot of overlaid transparencies (for highlights and such) it may be worthwhile to flatten them into solid colors too, but your character here is so small that it might not make all that much of a difference.
Logged
raiten
Guest
« Reply #3 on: April 13, 2010, 01:22:42 AM »

I think one of reasons might be that the game draws the entire level irregardless of the player's position. Changing the size of the window, I could see the entire stage, rather than just the part of it surrounding the player.

http://i391.photobucket.com/albums/oo355/sailormarcus/screen.png

I noticed that the game uses bitmaps for the background so maybe that's not the biggest part of your problem, but in addition to this, the enemies, objects etc which seemed to be vector-based were even animated when they're off screen. So basically you're using up part of the processor to draw and animate a lot of stuff the player doesn't even see. I don't know how you've coded the levels but if it's tiled, it should be really easy to make sure that only the necessary tiles are displayed and animated. If you've done something simpler, like maybe just arranging movie clips in the flash IDE, there's still things you can do that will probably improve performance, like making sure enemies off screen don't show or at least aren't animated.
« Last Edit: April 13, 2010, 04:43:04 AM by Marcus » Logged
Sam
Level 3
***



View Profile WWW
« Reply #4 on: April 13, 2010, 04:34:16 AM »

You could also 'rasterise' the animations for the characters.  During a loading screen you'd draw each frame of his animation to a BitmapData object (so creating an old-school sprite sheet), then during play you just display the right frame from that rather than redrawing the vector graphic each frame.

Some fellow has made a thingy that does this: Link
I've not actually used that, as I prefer to reinvent the wheel.  It might be useful as it is, but I suspect it's going to need alteration to work with multiple animations on a single character.

We're mostly talking about graphics rather than scripting!  Partially that's because we can't judge what's going on in code very easily from playing.  But also there isn't much going on in the game that should require heavy lifting in code, and drawing vector graphics is slow even though it's what Flash is specialises in.  If there were millions of enemies and bullets being created and destroyed, we could totally talk about linked lists and stuff.

Logged
rayteoactive
Level 1
*



View Profile WWW Email
« Reply #5 on: April 13, 2010, 07:40:53 PM »

Thanks for the advice guys. We managed to solve the lag (I think). Apparently, the programmer removed some codes and it works fine again.

I will see if I can figure out the reason behind and share it here if I can.
Logged

Bite Bite Bite Bitejacker!
http://secretbase.com.sg/
aeiowu
Level 10
*****


Greg Wohlwend


View Profile WWW Email
« Reply #6 on: April 13, 2010, 07:51:32 PM »

i had some real trouble jumping to that first floating block, like i couldn't even get to the tunnel and only landed on the block a couple times out of ~30 tries. maybe it'd be easier to judge if you uploaded to a page that had the flash object embedded with the correct dimensions. are you looking for feedback outside of the performance issues?
Logged

rayteoactive
Level 1
*



View Profile WWW Email
« Reply #7 on: April 14, 2010, 10:26:45 AM »

Ah... I'm sorry you had to try for so long. The game is pretty faulty at this point, and the help text and all were all missing still, so it might not be a good idea to try out the game play. I'll see if I have time to put it up in feedback when its all done  Beer!
Logged

Bite Bite Bite Bitejacker!
http://secretbase.com.sg/
salade
Level 4
****



View Profile
« Reply #8 on: April 14, 2010, 11:27:49 AM »

Yep, drawing the entire level is bad, but it seems like there was something else in there that was messing up the level physics. maybe just me... perhaps that is the code that got removed thought.

Also, I was only able to get to the aforementioned floating block by doing something like jumping off one of the walls. There was no animation for the wall jump, so if it's a bug... well, there you go.

Logged
davidp
Level 6
*



View Profile WWW
« Reply #9 on: April 14, 2010, 10:12:44 PM »

runs pretty fluid for me, at least these 5 minutes i've been messing around Shrug
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic