Right Screen Bug on Android

So I made a game for mobile using Solar2D, which I always run on emulator Solar2D provides and it runs smoothly and no bug. But then when I try my game using my phone there is a bug whenever I press the right side of the screen, my characters go to the right. The left side of the screen doing just fine, but the right side always doing that. I don’t know which part of my code doing that since my function to make hero move is by having a key listener named “right”. here is the link of my source code.

That seems like quite a lot of code to go through.

Just a hunch, but your problem may have to do with Android’s immersive sticky mode.

You’re setting native.setProperty( "androidSystemUiVisibility", "immersiveSticky" ) in main.lua. It’ll take a few frames fto kick in and it may be that your calculations and/or display object positions may be incorrect in the later scenes because the API call will change the available screen size once complete.

You can give it a quick test via:

timer.performWithDelay( 1000, function()
    composer.gotoScene( "scenes.menu" )
end )

If the bug disappears, then you’ve found your culprit and you can write a nicer fix. If it doesn’t, please write a more descriptive explanation of your issue.

if ( system.getInfo( "androidApiLevel" ) and system.getInfo( "androidApiLevel" ) < 19 ) then
	native.setProperty( "androidSystemUiVisibility", "lowProfile" )
else
	native.setProperty( "androidSystemUiVisibility", "immersiveSticky" ) 
end

system.activate("multitouch")

I already have this in my main.lua. I copy paste this settings from a youtube tutorial. Does it need to be removed?

Yes, you do. Give the timer test a try and see if it makes a difference.

it doesn’t make any differences. the problem still presist

i tried to change my key.name button to “mright” and the problem is solved. its weird but can you explain?

Not without going through the trouble of debugging your code.

I’m going to wager a guess the issue is with how key events are being dispatched. Something was probably sending “right” as the keyName to the listener, and probably still is. Now that you’re checking for "mright" inside the listener, the condition isn’t met and nothing happens.