Jump to content

Search the Community

Showing results for tags 'bullet shooting code'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. hi, i am following phaser tutorial . but, i don't understand the fire: function() code. please help me create: function () { ... this.bullets = []; // Add an empty sprite group into our game this.bulletPool = this.add.group(); // Enable physics to the whole sprite group this.bulletPool.enableBody = true; this.bulletPool.physicsBodyType = Phaser.Physics.ARCADE; // Add 100 'bullet' sprites in the group. // By default this uses the first frame of the sprite sheet and // sets the initial state as non-existing (i.e. killed/dead) this.bulletPool.createMultiple(100, 'bullet'); // Sets anchors of all sprites this.bulletPool.setAll('anchor.x', 0.5); this.bulletPool.setAll('anchor.y', 0.5); // Automatically kill the bullet sprites when they go out of bounds this.bulletPool.setAll('outOfBoundsKill', true); this.bulletPool.setAll('checkWorldBounds', true); this.nextShotAt = 0; fire: function() { if (this.nextShotAt > this.time.now) { return; } if (this.bulletPool.countDead() === 0) { return; } this.nextShotAt = this.time.now + this.shotDelay; // Find the first dead bullet in the pool var bullet = this.bulletPool.getFirstExists(false); // Reset (revive) the sprite and place it in a new location bullet.reset(this.player.x, this.player.y - 20); bullet.body.velocity.y = -500; },
×
×
  • Create New...