Created
August 22, 2014 12:46
-
-
Save dai-shi/8730a68ca0beca046c9e to your computer and use it in GitHub Desktop.
famo.us example for #165
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 #165</title> | |
| <link type="text/css" href="//code.famo.us/famous/0.2.2/famous.css" rel="stylesheet" /> | |
| <script type="text/javascript" src="//code.famo.us/lib/require.js"></script> | |
| <script type="text/javascript" src="//code.famo.us/famous/0.2.2/famous.js"></script> | |
| <script type="text/javascript"> | |
| require(['famous/core/Engine', 'famous/core/Surface', 'famous/core/Modifier', 'famous/physics/PhysicsEngine', 'famous/physics/bodies/Circle', 'famous/physics/forces/Force'], function() { | |
| var Engine = require('famous/core/Engine'); | |
| var Surface = require('famous/core/Surface'); | |
| var Modifier = require('famous/core/Modifier'); | |
| var PhysicsEngine = require('famous/physics/PhysicsEngine'); | |
| var Circle = require('famous/physics/bodies/Circle'); | |
| var Force = require('famous/physics/forces/Force'); | |
| var context = Engine.createContext(); | |
| var physicsEngine = new PhysicsEngine(); | |
| var force = new Force([0, 0.00001, 0]); | |
| 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(force, 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(); | |
| }); | |
| </script> | |
| </head> | |
| <body></body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment