mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
implemented throwing
This commit is contained in:
parent
8d34e4a001
commit
d679d61b64
2 changed files with 12 additions and 3 deletions
|
|
@ -102,3 +102,10 @@ function drop() {
|
|||
world.DestroyJoint(joint);
|
||||
joint = null;
|
||||
}
|
||||
|
||||
function throwItem(){
|
||||
drop();
|
||||
body = item;
|
||||
body.SetAwake(true);
|
||||
body.ApplyImpulse(new b2Vec2(-2, -.7), body.GetPosition());
|
||||
}
|
||||
|
|
@ -10,8 +10,10 @@
|
|||
<body>
|
||||
<canvas id="canvas" width="600" height="400" style="background-color:#333333;"></canvas>
|
||||
<br/>
|
||||
<button onclick="jump(dude)">move dude</button>
|
||||
<button onclick="jump(item)">move item</button>
|
||||
<button onclick="drop()">drop item</button>
|
||||
<button onclick="jump(dude)">move dude</button> <br/>
|
||||
<button onclick="jump(item)">move item</button><br/>
|
||||
<button onclick="drop()">drop item</button><br/>
|
||||
<button onclick="throwItem()">throw</button><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue