Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var config = {
- type: Phaser.CANVAS,
- width: 800,
- height: 600,
- parent: 'phaser-example',
- backgroundColor: '#9adaea',
- useTicker: true,
- scene: {
- create: create,
- update: update
- }
- };
- var bullet = [];
- var C = 100;
- var speed;
- var game = new Phaser.Game(config);
- function create ()
- {
- speed = Phaser.Math.GetSpeed(600, 6);
- for(var i = 0; i < C; i++) {
- bullet.push(this.add.rectangle(64, 72+i*3, 40, 40, color(i)));
- }
- }
- function color(i) {
- return 0x001100 * (i % 15) + 0x000033 * (i % 5);
- }
- // The update function is passed 2 values:
- // The current time (in ms)
- // And the delta time, which is derived from the elapsed time since the last frame, with some smoothing and range clamping applied
- function update (time, delta)
- {
- for(var i in bullet) {
- bullet[i].x += speed * delta;
- if (bullet[i].x > 864)
- {
- bullet[i].x = 64;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement