Jump to content
  • Advertisement
Sign in to follow this  
cptrnet

[web] Help with my game

This topic is 4414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello gamdev, I am trying to fix my game to be compatible with firefox. I am just javascript. I know I could use other things but its a really simple game with not really good graphics. It works just fine in IE but in Firefox or Mozilla when you press the space bar to jump in moves the webpage down and messes up the screen. Here is a link so you can see the problem. Link My guess it that it is writting some html down there, becuase on the main menu it doesn't do that. To create my sprites I am using this java script.
this.obj = document.createElement("IMG");
document.getElementsByTagName("body").item(0).appendChild(this.obj);


There might be some unexplained html somwhere else that I cannot find. Well my question to you isn't to fix it but is there a way that I can disable the page going down like that or what would cause that? Thanks for your help. **** EDIT **** - I have put a window.scroll(0,0); in there to debug the rest of the game. I know its a hacky way to do it. Is there anything else I can do? [Edited by - cptrnet on April 19, 2006 1:30:35 PM]

Share this post


Link to post
Share on other sites
Advertisement
You also have a problem with your messageboxes at gameover. They loop between Gameover and You died!. I used Firefox to play the game.

Share this post


Link to post
Share on other sites
Yeah I know there are a ton of problems with the firefox version that I need to work out, this is just the main one because no one can play it with the screen jumping like that.

Share this post


Link to post
Share on other sites
Basically what's probably happening is that the keyboard event from the spacebar has some default action - scrolling the page down.

In order to use the spacebar usefully for something else, you need to block the default action of that event.

The normal way to do this is by calling event.preventDefault() - which is the DOM events thing (As ever, MSIE has a completely different way of doing this).

Mark

Share this post


Link to post
Share on other sites
on w3 it says that the scroll event is not cancelable in which it gives a defintion of that saying you cannot cancel the event. Maybe I am misinterpreting this becuase I cannot find any real examples of canceling the scroll event or preventing the default. All my searches in google have come up with nothing. Maybe its because I really don't know what I am looking for. Can anyone help me with the preventDefault() function?

Share this post


Link to post
Share on other sites
That would be such a pain to push shift. Space bar is huge and for fast reactions I think it would better to hit a bigger key than a smaller one. Besides I ran into another problem when you hit the down arrow key, not that theres any functionality there but what if someone hits it. I just can't change keys because the problem will still be there.

Share this post


Link to post
Share on other sites
The scroll event may not be cancellable, but the key press event should be. If you cancel the keyboard event, it won't then generate a scroll request.

I am pretty sure I've done this before, so either

- Mozilla allows the event to be cancelled anyway, shunning the W3 spec
OR
- The keyboard event is cancellable.

Mark

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!