How do I override arrow Up

Get help using Construct 2

Post » Tue May 13, 2014 10:45 am

Hello,

I have a game that does jump on arrow up, but arrow up is also default key in browsers for moving content up. And every time user presses arrow up the game character does jump but it also moves complete content of the page up.

Is there a way to disable browser reacting to this and leave arrow up only to the game.

Thank you.
B
5
Posts: 27
Reputation: 279

Post » Tue May 13, 2014 11:30 am

Think you have a better chance of checking out with the browser you are using if it can be done there. I dont think it have anything to do with C2, otherwise you can use the nodeweb kit one.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Tue May 13, 2014 11:41 am

This is the game so it will be in many different browsers. Shouldn't Construct2 override arrow up at least it says like that in documentation.
B
5
Posts: 27
Reputation: 279

Post » Tue May 13, 2014 1:29 pm

This is the game so it will be in many different browsers. Shouldn't Construct2 override arrow up at least it says like that in documentation.

I cant find in the documentation where it says that? but i get your point. I dont know how you can do it, doesnt seem to be any setting for it from what i can see :(
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Tue May 13, 2014 2:26 pm

This shouldn't happen. This is happening when you preview on browser, or after you upload the game on ftp?
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Tue May 13, 2014 6:43 pm

Ok here is the solution.
If you want to disable key for good, you put the On Key Event but with empty action.

This happens when you have a key that you use in game but not every time. For example i have motorbike that jumps only when its on ground. So users can press up to jump if in air but it will not do jumps because motorbike is not grounded.

I expected Construct2 to catch this and not let it to browser because i have event OnKeyDown but just with additional check is motorbike grounded. Looks like Construct2 catches key up, checks is grounded if not it actually releases event to browser. Not exactly sure is this what's happening but it looks like it is.

It's important that you can go around this by adding event OnKeyDown that does nothing so it catches it every time. After that event you can make your own logic with other one.

Hope this helps.
B
5
Posts: 27
Reputation: 279

Post » Wed Jun 11, 2014 3:12 pm

I to have a game with OnKeyDown...I'm having the same problem except only in Firefox. In Chrome the screen doesn't bounce around at all. but Firefox moves up (just a little bit) with up arrow and the same for the down arrow. It's very annoying.

@list3ner seems like a decent work around, but that can't be the way to solve it.

Anyone else know?
B
98
S
32
G
16
Posts: 1,204
Reputation: 16,715

Post » Wed Jun 11, 2014 8:47 pm

Adding an empty event to block the browser default action is documented behavior. It only works with the 'On pressed' triggers, not the 'Is key down' conditions.
Scirra Founder
B
398
S
236
G
88
Posts: 24,433
Reputation: 194,635

Post » Thu Jun 12, 2014 12:23 am

@Ashley thanks, I added 3 Events: On Space Pressed, On Up Arrow Pressed, On Down Pressed. That fixed it.

I guess I was worried it was making the code do unnecessary checks, but then I realized I already have code checking for space bar presses, but since there's an Action that is triggered it must somehow not block the rest? I'm happy it works but still a little foggy on why it works.

Yaay, I can use Firefox again..
B
98
S
32
G
16
Posts: 1,204
Reputation: 16,715


Return to How do I....?

Who is online

Users browsing this forum: Kin, mickclarke, tinhofiel, TRMG, Yahoo [Bot] and 39 guests