2012-05-23 4 views
0

javascript + html5의 캔버스 용 기본 엔진을 마쳤습니다. 아주 초보적인. 브라우저에서는 작동하지만 iOS에서는 작동하지 않습니다.HTML5의 캔버스 + Javascript 코드가 iOS에서 작동하지 않습니다.

아직 사파리 모바일에 구현되지 않은 기능을 사용 했습니까? :(

http://bluecodestudio.com/kipos/gametest.html

keyboardJS.init(), 당신이 당신의 이벤트 콜백에 바인드() 메소드를 사용하고 있습니다.에서

답변

3

document.addEventListener("keydown", this.keyIsDown.bind(this)); 
document.addEventListener("keyup", this.keyIsUp.bind(this)); 
바인드를 지원하지 않습니다 (모바일 사파리 포함)

사파리 () 메서드를 호출해야합니다. 폴리 필을 제공해야합니다.

/** 
* Bind.js 
* Copyright 2010, WebReflection 
* License: http://www.opensource.org/licenses/mit-license.php 
*/ 
if (Function.prototype.bind === null || Function.prototype.bind === undefined) { 
    Function.prototype.bind = (function (slice) { 
     // (C) WebReflection - Mit Style License 
     function bind(context) { 
      var self = this; // "trapped" function reference 
      // only if there is more than an argument 
      // we are interested into more complex operations 
      // this will speed up common bind creation 
      // avoiding useless slices over arguments 
      if (1 < arguments.length) { 
       // extra arguments to send by default 
       var $arguments = slice.call(arguments, 1); 
       return function() { 
        return self.apply(
         context, 
        // thanks @kangax for this suggestion 
         arguments.length ? 
        // concat arguments with those received 
          $arguments.concat(slice.call(arguments)) : 
        // send just arguments, no concat, no slice 
          $arguments 
        ); 
       }; 
      } 
      // optimized callback 
      return function() { 
       // speed up when function is called without arguments 
       return arguments.length ? self.apply(context, arguments) : self.call(context); 
      }; 
     } 

     // the named function 
     return bind; 

    } (Array.prototype.slice)); 
} 
+0

오, 선생님! 많은 칭호를받습니다. 완벽하게 작동합니다. :) –

관련 문제