Created
November 5, 2014 14:17
-
-
Save dai-shi/6e3e56edb906807b4a1b to your computer and use it in GitHub Desktop.
famo.us example for #448
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>famo.us example for #448</title> | |
| <link type="text/css" href="//code.famo.us/famous/0.3.0/famous.css" rel="stylesheet" /> | |
| <script type="text/javascript" src="//code.famo.us/famous/0.3.0/famous-global.js"></script> | |
| <script type="text/javascript"> | |
| var Engine = famous.core.Engine; | |
| var Surface = famous.core.Surface; | |
| var Modifier = famous.core.Modifier; | |
| var PhysicsEngine = famous.physics.PhysicsEngine; | |
| var Circle = famous.physics.bodies.Circle; | |
| var Collision = famous.physics.constraints.Collision; | |
| var context = Engine.createContext(); | |
| var physicsEngine = new PhysicsEngine(); | |
| var collision = new Collision(); | |
| var circles = []; | |
| var createCircle = function() { | |
| var surface = new Surface ({ | |
| size: [40, 40], | |
| properties: { | |
| backgroundColor: 'lightblue', | |
| borderRadius: '20px' | |
| } | |
| }); | |
| var circle = new Circle({radius: 20}); | |
| physicsEngine.addBody(circle); | |
| physicsEngine.attach(collision, circles, circle); | |
| circles.push(circle); | |
| var modifier = new Modifier({origin: [0.5, 0.5]}); | |
| context.add(modifier).add(surface); | |
| Engine.on('prerender', function() { | |
| modifier.setTransform(circle.getTransform()); | |
| }); | |
| return circle; | |
| }; | |
| var c1 = createCircle(); | |
| var c2 = createCircle(); | |
| var c3 = createCircle(); | |
| setTimeout(function() { | |
| physicsEngine.removeBody(c1); | |
| physicsEngine.removeBody(c2); | |
| }, 1000); | |
| </script> | |
| </head> | |
| <body></body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment