Jump to content

Key timeDown is different in firefox to chrome


Dream Of Sleeping
 Share

Recommended Posts

Hello. I need to determine how long a key has been pushed down for. Unfortunately the 'duration' variable isn't updated until after the key has been pushed down for about 250 milliseconds, as it's only updated when there is a new key event. So I was using the timeDown property and using new Date().getTime() to work out how long has passed. This works great in chrome and safari. Does not work in firefox. When printing out the value of timeDown, in firefox I get a very small number with only 6 digits. Any ideas what's wrong there?

 

 

I can't test it in Internet Explorer yet as I'm just getting a white screen. Nothing at all. My fault for not testing it sooner. Tomorrow I'm going to have comment out nearly all code, and introduce it line by line to see what the problem is. Is there any known issue with Internet Explorer, that might help me track it down? I get no error, just nothing.

 

Edit: I've now found a lot of phaser games that don't work on internet explorer. So i guess this is a known issue. It works when I force it to use canvas. The key thing works as expected in IE as well. Just firefox that doesn't work correctly.

 

In fact I'm taking tomorrow off this is stressing me out.

Link to comment
Share on other sites

Yes timeDown isn't the actual time (i.e. timezone style time), it's the game timer. If the browser supports high resolution timers like Chrome does this will be quite different to others that don't. To be honest I would just listen for the key down, set your own local time value (using Date()) and then compare the difference as needed.

 

re: IE, it depends which version and very often the pages that contain the games aren't set-up correctly re: meta tags/doc type, which forces IE to drop into quirks mode and stops canvas working at all. If you get no debug console errors then I would put money on it being a doctype/quirks issue (the white screen) rather than anything in your code.

Link to comment
Share on other sites

Thanks Rich for replying and for your patience. I'm really enjoying using phaser.

 

The person who goes by the name of LessMilk who is making one game a week with phaser,  seems to have the problem of games not working in IE or Opera. Here is is recent flappy bird clone. http://www.html5gamedevs.com/topic/4046-tutorial-how-to-make-a-flappy-bird-in-html5-with-phaser/

 

Can you spot what's wrong here? Or maybe it works for everyone else but not me.

Link to comment
Share on other sites

Ahh that - that's the lovely IE11 WebGL bug with pre-multiplied alpha. It's an issue Pixi has :( (well it's not entirely their fault, but it stems from down there). The only fix is to force canvas in the game constructor - or there is a small bit of code in Game.js which detects IE11 and applies canvas for you, so you can carry on using webgl in chrome/etc, which was added specifically for this, so is worth un-commenting I'd say.

Link to comment
Share on other sites

Opera compatibility is a lot better under Pixi 1.5 now (and hence is in the new version of Phaser), but the IE11 issue remains. Hopefully Mat said he'll fix it this weekend, which is good because it will make the fix work in Phaser 2 when we launch - but he may not have time, so fingers crossed. In the meantime use the check I put in place in Game.js to resolve it.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...