Last active
August 29, 2015 14:05
-
-
Save dai-shi/07a4ffb621fbc9ce6619 to your computer and use it in GitHub Desktop.
famo.us example for #173
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 #173</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 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); | |
context.add(surface); | |
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