espace Posted November 2, 2017 Share Posted November 2, 2017 hi, i use http://jshint.com/ to visualize my errors of syntax and it say that a semi-colon is missing in this line: game.time.events.add( time_appears_enemies,function(){this.flag_wait_before_fire=true},this); Have you an idea ? Quote Link to comment Share on other sites More sharing options...
Gio Posted November 2, 2017 Share Posted November 2, 2017 true; It also exceeds 80 characters (not a bad thing IMO, but jshint will complain about it) espace 1 Quote Link to comment Share on other sites More sharing options...
mattstyles Posted November 2, 2017 Share Posted November 2, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.