Awesome q2a theme

How to call a function inside a function?

0 like 0 dislike
32 views
how to call a function goUser which is in function start_game ?
Screen
5aec51c67cb23673554856.png
by | 32 views

2 Answers

0 like 0 dislike
Very likely the errors with this long time on js wrote.

$(document).ready(function() { var Game = { isGameStarted: false, start: function(event) { // this method needs a lock, but it'll do for now. if (true == this.isGameStarted) { return; } if ($('.user_name').val() == ") { $('.errors').html('Enter the name!'); return; } this.isGameStarted = true; $('.start_game_box').addClass('hidden'); $('.user').removeClass('hidden'); $(document).keydown(this.goUser); }, goUser: function(event) { if (false == this.isGameStarted) { return; } var pz_user = $('.user').offset(), top = pz_user['top'], left = pz_user['left']; if (event.which === 38) { var top = top -5; $('.user').css('top', top + 'px') } if (event.which === 40) { var top = top +5; $('.user').css('top', top + 'px') } if (event.which === 37) { var left = left -5; $('.user').css('left', left + 'px') } if (event.which === 39) { var left = left +5; $('.user').css('left', left + 'px') } } }; $('.btn_start').on('click', Game.start); });
by
0 like 0 dislike
could code fold. where the call goUser what's going on?
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Jun 12, 2019 by Shing
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 12, 2019 by Nikolino
0 like 0 dislike
2 answers
110,608 questions
257,187 answers
0 comments
40,796 users