寺子屋クスール @station5

Download 寺子屋クスール @STATION5

Post on 24-Jan-2015

1.940 views

Category:

Technology

6 download

Embed Size (px)

DESCRIPTION

2010年5月30日 STATION5で行われた寺子屋クスールのセッション2 [Flash CS5x科学 byくるくる研究室]で使用されたスライドです。

TRANSCRIPT

  • 1. Flash

2. http://labs.kuru2jam.com/ @hara3@biscuitjam 3. http://labs.kuru2jam.com/ 4. 5. 6. Flash Lite 4 7. Flash 8. ActionScript3 ! 9. 10. (gravity) (bounce) (vy) 11.

  • EnterFrame

12. 13. this . addEventListener ( Event . ENTER_FRAME ,_enterFrameHandler); function_enterFrameHandler(e: Event ){ // vy += gravity; // y += vy; // // if ( y+height/ 2 >stage . stageHeight ){// y=stage . stageHeightheight/ 2; // vy *= bounce;} } 14. 15. 16. this . addEventListener ( TouchEvent.TOUCH_TAP , onTouchTap); functiononTouchTap(e: TouchEvent ){ addBall(e. stageX ,e. stageY ); } 17. 18. DeciceCentral CS5 19. 20. 21. 22. fscommand2 23. Accelerometer 24. //Accelerometer varacc: Accelerometer=new Accelerometer (); // varisSupportedAcc: Boolean=Accelerometer.isSupported ; if (isSupportedAcc){ // acc. addEventListener ( AccelerometerEvent . UPDATE ,_updateAccHandler); } function_updateAccHandler(e: AccelerometerEvent ){ // } 25. 26. // varpreF: Number= 0; function_updateAccHandler(e: AccelerometerEvent ){ // varax: Number= e. accelerationX ; //X varay: Number= e. accelerationY ; //Y varaz: Number= e. accelerationZ ; //Z // ( ) varf: Number= ax * ax + ay * ay + az * az; // // varm: Number=Math . abs (f - preF); if (m > 0.1){ addBall( Math.random () * 240,-30); } // preF = f; } 27. 28. 29. 30. 31. AS3 32. AS3 33. Box2DFlashAS3 http://sourceforge.net/projects/box2dflash/ 34.

  • (world)

35.

  • (Body)
  • Body
  • Body
  • Body

36. ( ) functioninitBox2d(){ // vargravity:b2Vec2 = new b2Vec2(0.0, 10.0); // _world =newb2World( gravity, true); // addBall(120,40); // addEventListener ( Event . ENTER_FRAME , update); } 37. functionaddBall(xx: Number , yy: Number ){ // varcircleDef : b2CircleShape =newb2CircleShape(); varradius :uint= 20; circleDef.SetRadius(radius / _m_physScale); // _fixtureDef.friction = 10; _fixtureDef.density = 10; _fixtureDef.restitution = 0.9; _fixtureDef.shape = circleDef; 38. ( ) // varbodyDef : b2BodyDef =newb2BodyDef(); bodyDef.type = b2Body.b2_dynamicBody;// bodyDef.position.Set(xx / _m_physScale, yy / _m_physScale); // (Ball) bodyDef.userData =newBall(); bodyDef.userData. x= bodyDef.position. x ; bodyDef.userData. y= bodyDef.position. y ; addChild (bodyDef.userData);// (Ball) // bodyDef varcircleBody : b2Body = _world.CreateBody(bodyDef); // circleBody circleBody.CreateFixture(_fixtureDef); } 39. functionupdate(e: Event ): void { // _world.Step(_m_timeStep, _m_iterations, _m_positionIterations); _world.ClearForces(); // for( varbb:b2Body = _world.GetBodyList(); bb; bb = bb.GetNext()){ varmc:MovieClip = MovieClip(bb.GetUserData()); if(mc){ mc. x= bb.GetPosition().x * _m_physScale; mc. y= bb.GetPosition().y * _m_physScale; mc. rotation= bb.GetAngle() * (180 /Math.PI ); } } } 40. 41. 42. Multitouch . inputMode= MultitouchInputMode . GESTURE ; GPS Geolocation ( AIR ) 43. 44. FlashLite4 45.