JavaScriptã§ç©çã·ãã¥ã¬ã¼ã·ã§ã³
Box2DFlashAS3ã¨ããAS3ç¨ã®ç©çã·ãã¥ã¬ã¼ã¿ãããããã§ããã
ãåãECMAScriptã ããASãå°ãç½®æããã°JSã§ãåãããããï¼ã
ã¨è¨ãåãªãæãä»ããå®è¡ãã¦ã¿ããããã£ããåãã¾ããã
ã¾ãããã³ãã«åããªãã¦ãæ£ç´èªåã§ãã³ã³ã£ãã
ã¾ãããã£ããã¨ã¯è¨ã£ã¦ãé£ä¼å¾åããã¡ã³ã¡ã³ãã£ã¦ãã®ã§2-3æ¥ããã£ã¦ã¾ããã©ã»ã»ã»ã
http://blog.technohippy.net/box2djs/demo.html (ã¾ã FireFoxéå®)
http://box2d-js.sourceforge.net/
ã¨ãããããåã¨ãåè§ã¨ãå¤è§å½¢ã¨ãå転ã¸ã§ã¤ã³ãã試ãã¦ã¿ã¾ããã
ãã³ãã«ä¸èº«ãä¸åç解ããªãã¾ã¾ç½®æããã ããªã®ã§ãä¸ã®ãã¢ã§ä½¿ã£ã¦ãªãæ©è½ãåããã©ããã¯è¬ãã¨ãããããã¶ãããã¤ãã¯åããªãã¨æãã
ããå°ããã¡ãã¨ç¢ºèªããããã½ã¼ã¹ãæ´çãã¦SourceForgeããªã«ãã«ä¸ãã¾ããããã¨ã«ããåããã®ãããããã®ã§ã¨ããããå ¬éãï¼ãã10åãããæ©ãåãããå®ç¨ã«è¶³ããã ãã©ãªãã»ã»ã»ï¼
ã³ã¼ãæç²
å½ããåã ãã©ãåãæ¸ããªããã¨ãé¤ãã°ä½¿ãæ¹ã¯Box2DFlashAS3ã¨åãã§ãã
// Worldãçæ function createWorld() { var worldAABB = new b2AABB(); worldAABB.minVertex.Set(-1000, -1000); worldAABB.maxVertex.Set(1000, 1000); var gravity = new b2Vec2(0, 300); var doSleep = true; return new b2World(worldAABB, gravity, doSleep); } // åãçæ function createBall(world, x, y) { var ballSd = new b2CircleDef(); ballSd.density = 1.0; ballSd.radius = 10; ballSd.restitution = 0.2; var ballBd = new b2BodyDef(); ballBd.AddShape(ballSd); ballBd.position.Set(x,y); return world.CreateBody(ballBd); } // ã·ãã¥ã¬ã¼ã·ã§ã³ã1ã¹ãããé²ãã world.Step(timeStep, iteration);