JAVASCRIPT   9

wrecking ball.js

Guest on 30th May 2021 09:50:15 PM

  1. var config = {
  2.     type: Phaser.AUTO,
  3.     width: 800,
  4.     height: 600,
  5.     backgroundColor: '#1d1d1d',
  6.     parent: 'phaser-example',
  7.     physics: {
  8.         default: 'matter',
  9.         matter: {
  10.             gravity: {
  11.                 y: 0.05
  12.             },
  13.             debug: true
  14.         }
  15.     },
  16.     scene: {
  17.         preload: preload,
  18.         create: create
  19.     }
  20. };
  21.  
  22. var game = new Phaser.Game(config);
  23.  
  24. function preload ()
  25. {
  26.     this.load.image('crate', 'assets/sprites/crate.png');
  27.     this.load.image('crate32', 'assets/sprites/crate32.png');
  28. }
  29.  
  30. function create ()
  31. {
  32.     this.matter.world.setBounds();
  33.  
  34.     //  Increase the solver steps from the default to aid with the stack
  35.     this.matter.world.engine.positionIterations = 30;
  36.     this.matter.world.engine.velocityIterations = 30;
  37.  
  38.     var stack = this.matter.add.imageStack('crate32', null, 300, 50, 5, 18, 30, 0, { _mass: 0.5 });
  39.  
  40.     this.matter.add.mouseSpring();
  41. }

Raw Paste


Login or Register to edit or fork this paste. It's free.