Jump to content

Shooting Bullets Automatically


willdta
 Share

Recommended Posts

What I'm trying to achieve is having an enemy shoot bullets randomly with a time interval. 

Right now I just have a fire method setup on space-bar for my main player sprite but I want to have enemy sprites shooting bullets automatically.

Is there a method/example that allows you to do so?

Link to comment
Share on other sites

Use timer?

 

var Enemy = function() {
    // object init and other stuff

    // start firing
    game.time.events.add(500, this.fire, this);
}

Enemy.prototoype.fire = function() {
    // firing code
    game.time.events.add(500, this.fire, this);
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...