Jump to content

missing semi-colon in this line ?


espace
 Share

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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