Help on mole unearther project (how to create videogames with phaser.js course)

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

I was going through the project when I gut stuck on question 10

Now we have a function, onBurrowHit(), that we can use to execute when the user hits a key. In update(), there are three conditions set up for you that will identify when the user hits one of the keys:

if (Phaser.Input.Keyboard.JustDown(gameState.jKey)) { } else if (Phaser.Input.Keyboard.JustDown(gameState.kKey)) { } else if (Phaser.Input.Keyboard.JustDown(gameState.lKey)) { } 

Inside each condition, call the onBurrowHit() function with the corresponding 'j', 'k', or 'l' key that the user hit.

I dont get what this means, heres why. This is the hint:
If you want to check your work, inside onBurrowHit(), add a call to console.log() and pass in the key parameter. You should be able to hit the J, K, or L key, and see the corresponding key log out in the console.

If you’ve never used the browser JavaScript console before, this guide from Google is a good guide to opening it and seeing logged values.

Feel free to remove the console.log() call when you’re ready to move on.

So I did the task and its fien, but the key wont ‘log’ in the game.
what do they mean by when you should be able to see the corresponding key log out in the console?

I clicked the keys and it does not work, what am I supposed to do to, or is it already correct?

heres a github of the part in at

The key won’t be logged in the game. It should be logged to the browser console.

What browser are you using?

For Example, in Chrome, you can bring up the console by clicking “More Tools > Developer Tools” and then selecting the Console tab.

scrn1

scrn2

im using firefox

but I dont get it, where should this be called?

can I skip this if there no error in the game?
or should I be able to test it first?

EDIT : found the console thing, going to check if it works, sorry my internet is slow today

Ok so the console thing showed a phaser thing, is that what the question was asking for?
it seems to be printing the j k and l when the games on, it that it though? or am I wrong?

I haven’t done this project and don’t have access to the instructions. But based on your first post, it is only meant for your benefit as a way to check whether your key presses are successfully triggering the onBurrowHit function.

From what I surmise, the intent is that you will run your game and also keep your browser console open. Whenever you press one of the keys (j, k or l), if you have set up your conditions and onBurrowHit function properly, then because of your debugging statement console.log(key);, the appropriate string 'j', 'k' or 'l' will be logged to the console.

For example, after running your game, if you press the j key twice followed by a single press of the k key, then you will see the output

'j'
'j'
'k'

in the console. This confirms that your if conditions and onBurrowHit function are working properly so far. As the instructions in your first post suggest, you can then

“Feel free to remove the console.log() call when you’re ready to move on.”