willdta Posted March 14, 2018 Share Posted March 14, 2018 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 More sharing options...
elkranio Posted March 15, 2018 Share Posted March 15, 2018 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 More sharing options...
Recommended Posts