Guest User

JS Collision box code for streamlabs tip Jar (incomplete)

a guest
Jul 30th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jarEl.src = `https://cdn.streamlabs.com/static/tip-jar/jars/glass-pint.png`;
  2.  
  3. /* The code I'm using to try and get a circular collision box - NOT WORKING */
  4.  
  5. cupBase[1] += 10;
  6. circleBody = new p2.Body({ mass: 0, position: [cupBase[0], cupBase[1]] });
  7. circleShape = new p2.Box({ width: 140, height: 30 });
  8. circleShape.material = this.materials.wall;
  9. circleBody.addShape(circleShape);
  10. this.world.addBody(circleBody);
  11. this.world.addBody(createCircleBody(0, 40);
  12.  
  13. /*  The base code that works
  14. cupBase[1] += 10;
  15. boxBody = new p2.Body({ mass: 0, position: [cupBase[0], cupBase[1]] });
  16. boxShape = new p2.Box({ width: 140, height: 30 });
  17. boxShape.material = this.materials.wall;
  18. boxBody.addShape(boxShape);
  19. this.world.addBody(boxBody);
  20. this.world.addBody(this.createRectangleBody([cupBase[0] + 68, cupBase[1] + 133], 300, 30, 85));
  21. this.world.addBody(this.createRectangleBody([cupBase[0] - 68, cupBase[1] + 133], 300, 30, -85));
  22. */
Add Comment
Please, Sign In to add comment