[SOLVED] Losing and Winning the game problem

Hello another problem i’m encountering rn in my game is that after winning or losing the game the mouse cursor doesn’t show up i still need to press esc. Is there anyway that pressing esc won’t be necessary. i just need this and the timer and my game will be done? please i need your help

also everytime finish the game and click home button this shows up

and if possible have a 1 on 1 consultation for questions. thank you just having trouble with this coding for a long time.

Hi @Kwangbae_IZONE,

For your mouse cursor issue, most likely somewhere you are enabling pointer lock, search for a line like this and remove it:


Its an fps game so i think that code is important or is it not?

If you don’t want the mouse pointer to be hidden on click and require pressing ESC to show again, then you can safely remove it. It won’t affect anything else.

but i think want the mouse pointer to be hidden when playing however after changing scenes, for example winning, i don’t want it hidden so that the esc button won’t be necessary is there a code for that instead?

    if(result.other.name == 'trigger') {
        if (counter == 0) {
        var SceneToOpen = this.app.getSceneUrl('Victory Page');
        counter += 5;
        var CurrentScene = this.app.root.findByName('Root');

Then you can similarly call the following method to disable pointer lock, without having to press ESC:


i tried it but this pops up

what do i do?

My bad

Hi @Kwangbae_IZONE! It looks like there is a typo in your code.

1 Like

Yup its working now thank you so much!!

however how do i deal with this problem now i cant seem to right click bc of this

In your previous scene you have created an event for mouse click. If you change a scene you have to make sure you stop this event using .off. On the page below you can see how you can do this.


i somewhat got grasp of what should be done using .off however its still kinda confusing for me as a new programmer.

this.playerEntity.script.player.app.off(‘move’, onPlayerMove);

so in this sample code. what is “playerEntity” where is it taken from. and the ‘move’

really sorry for this

this is where the error is coming from so how do use .off in here

Where do you call your shoot function and where is that call coming from?



Yes, for mouseDown you have created an event in the initialize function. So for that .on event you have to create an .off event too. Something like below.

this.on('destroy', function() {
    this.app.mouse.off(pc.EVENT_MOUSEDOWN, this.mouseDown, this);

do i put it here?

No, it need to be in the initialize function after you have created the .on event for mouseDown.

damn I appreciate your help a lot however i want to apologize simply because that so hard for me to follow through. and i can’t seem to know how to do it no matter how much i analyze it

salute to you guys for being able to understand programming