wiln / jiglibflash

Automatically exported from code.google.com/p/jiglibflash
0 stars 0 forks source link

Modified AbstractPhysics.as - Pausing and Timer bugs Fixed #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi all,

There were two bugs/problem that I discovered while I was developing a game 
with JigLib. 

First one is, you can't pause the JigLib. Because it uses getTimer() and it 
never resets it.

The second one, sometimes Flash can freeze. But when it freezes timer continues 
to count. This can cause weird situations and breaks whole scene. For example 
when I right click in any JigLib projects, Flash freezes. When I close the 
right click menu by left clicking the stage, rigid bodies move through other 
rigid bodies.

So I modified AbstractPhysics file. I added a function called resetTimer()

When you want the engine to work again after pausing, you basically call 
afterPause() method. This resets the initTimer property and also fixes the 
pause issue.

I added a useTimer property. When you create your physics class you can set 
useTimer to false or true:

AbstractPhysics(speed,useTimer)

If useTimer is true, physicsSystem.integrate uses timer. If Flash freezes this 
can break your project. But if it is false then physicsSystem.integrate always 
uses a stable number. When Flash freezes, your project never breaks down. But 
FPS can reduce.

I attached modified AbstractPhysics.as file.

Cheers!

Original issue reported on code.google.com by yagizgur...@gmail.com on 15 Sep 2010 at 11:42

Attachments:

GoogleCodeExporter commented 9 years ago
Hi! 
I'm also fighting with the freezing problem, but with no success yet. 
I'm using Papervision3DPhysics plugin.
Using your patch didn't seems to solve the issue. 
Please clarify the magic number 
this.frameSpeed = speed/142 (???)
maybe tweaking this would help.

Regards,
Vitaly, Ukraine

Original comment by vit....@gmail.com on 25 Nov 2010 at 8:39