espace

missing semi-colon in this line ?

Recommended Posts

Styling can be a tricky subject but putting that all on one line (hence the 80 character warning) is both difficult to read and difficult to maintain.

game.time.events.add(time_appears_enemies, function () {
  this.flag_wait_before_fire = true;
}, this);

This is far more readable and easier if you need to make changes, to make it (easier to) testable you should probably go one step further and extract the anonymous function, but, given its using `this` testing is harder anyway so, meh. 

Also, that anonymous function, you can name it:

game.time.events.add(time_appears_enemies, function onEnemyAppear () {
  this.flag_wait_before_fire = true;
}, this);

This way if you get an error somewhere it'll turn up as a named function in the stack trace making your debugging job a little easier.

Also also, semicolons aren't required in either in the single-line version you posted or this one, not by JS anyway, although, you're enforcing them with your lint rules, hence you need one at the end of the function body.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.