Browser moving when pressing keys

Get help using Construct 2

Post » Wed Apr 25, 2012 1:10 am

Hi Constructors League!!

I have a little problem that I do not know how to fix!

We are almost ready to put our game on line (BETA) and I am customizing the index page of the construct exported game(index.html).

Te question is : How can I block the browser to move when pressing the arrow keys (Up and Down). My game needs those keys to move the main character but when doing that, the entire page moves with it.

I know this is not a direct Construct issue but if some one can give me a hand I will be eternally grateful.

Thank you for reading!!
B
3
G
1
Posts: 6
Reputation: 937

Post » Wed Apr 25, 2012 4:29 am

To maintain the browser usability when viewing C2 games, C2 only blocks keys which are used. Behaviors with default controls that are the arrow keys block the controls. Otherwise, drop in the Keyboard object and add an 'On key pressed' event for that key (not 'Is pressing', the trigger version). This will block the key and make C2 handle it, which should prevent scrolling. You might want to do the same for spacebar which is page-down in some browsers.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Aug 10, 2012 4:37 pm

Hi!

I'm having the same problem with my game but only in the Scirra arcade.
It works fine if hosted.

Any ideas?

Scirra arcade
Hosted version
B
9
S
3
G
3
Posts: 39
Reputation: 3,112

Post » Mon Aug 13, 2012 1:38 pm

UPDATE: I tried using blank events with "when arrow pressed" but is still not working. I tried embeding the code (given in the arcade) into a scrolling website and it works fine. The problem is with the scirra arcade webpage.

There's something i'm missing here?

The problem is I didn't manage to find a way to delete my game in the arcade so anyone who may step into it will shut it down in seconds and that's bad publicity.
B
9
S
3
G
3
Posts: 39
Reputation: 3,112

Post » Fri Aug 24, 2012 6:56 am

I have had this issue as well. The "Simple" solution of adding events for the buttons doesn't seem to work, especially since I am using the spacebar for some actions, and they still cause scrolling issues.

Any progress on how to fix this?

If not I have a sort of work around. My test project is self hosted, so I have complete control of the page it is on. I simply removed anything that would cause the page to be too tall (ie taller than the average browser viewport height).

I have a comment form on my page, and I solved this problem by giving it a fixed position, and having it slide out when the user hovers over the comments section with their mouse.

Have a look: http://games.mikemalaska.com/test/
B
15
S
3
Posts: 6
Reputation: 1,448

Post » Fri Aug 24, 2012 9:45 am

The user must click inside the game before it will get keyboard input. Then, in addition to that, you need the empty 'On key pressed' events. AFAIK this is working for a number of games on the Arcade - if it's not working for you could you share your .capx?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580


Return to How do I....?

Who is online

Users browsing this forum: chcteacher, Televangelist and 24 guests