javascript - Drawing a simple circle using Crafty.js and Box2d -
I'm trying to draw a simple circle by using box2d with crafty.js, but I get it to attract it Jsfiddle may not be able to:
Look at this part of the code:
var ball = crafty.e ("2D, canvas, color, box 2D , Ball ") .attr ({X: 10, y: 15, z: 5}). Color ("#FFF") .box2d ({bodyType: 'dynamic', density: 1.0, friction: 2, restoration: 0.2, shape: 'circle'}). OnContact ("Floor", Function (Data) {Warning ("Hi");}); The strange thing about this is that warning is executed but the ball is not showing up.
Box2dWeb- 2.1.a.3.js box2d.js Try downloading this source to crafty.js <, and try
and see if it works for you. P>
OK, I'm working on your code, it seems that reference library clever + box 2D is a modem created by a user who has created a pong game.
You can add width to ball object in .attr w and height h attribute. var ball = crafty.e ("2D, canvas, color, box 2D," ball ") .attr ({x: 10, y: 15, z: 5, w ("Body": "dynamic", density: 1.0, friction: 2, retribution: 0.2, shape: 'circle'}). Contact ("bottom" ", Function (data) {alerts (" hi ");}); If you want the circle box box to be outlined on , color Delete in the string logic of crafty.e and delete the .color property var ball = crafty.e ("2D, canvas, ball, box 2D, ") .attr ({x: 10, y: 15, z: 5 OnContact (" floor ", function (data). (2: 2, retror Ning: 0.2, shape: 'circle'}) .box2d ({bodyType: 'dynamic', density: 1.0, friction: {warning ("hi");}); That it helps :)
Comments
Post a Comment