Guest User

Untitled

a guest
Jan 22nd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var config = {
  2.     type: Phaser.CANVAS,
  3.     width: 800,
  4.     height: 600,
  5.     parent: 'phaser-example',
  6.     backgroundColor: '#9adaea',
  7.     useTicker: true,
  8.     scene: {
  9.         create: create,
  10.         update: update
  11.     }
  12. };
  13.  
  14. var bullet = [];
  15. var C = 100;
  16.  
  17. var speed;
  18.  
  19. var game = new Phaser.Game(config);
  20.  
  21. function create ()
  22. {
  23.     speed = Phaser.Math.GetSpeed(600, 6);
  24.     for(var i = 0; i < C; i++) {
  25.       bullet.push(this.add.rectangle(64, 72+i*3, 40, 40, color(i)));
  26.     }
  27. }
  28.  
  29. function color(i) {
  30.     return 0x001100 * (i % 15) + 0x000033 * (i % 5);
  31. }
  32.  
  33. //  The update function is passed 2 values:
  34. //  The current time (in ms)
  35. //  And the delta time, which is derived from the elapsed time since the last frame, with some smoothing and range clamping applied
  36.  
  37. function update (time, delta)
  38. {
  39.  
  40.     for(var i in bullet) {
  41.       bullet[i].x += speed * delta;
  42.      
  43.       if (bullet[i].x > 864)
  44.       {
  45.           bullet[i].x = 64;
  46.       }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment