Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome 我的Dart项目没有';即使我将其编译为js,t也可以工作。它只适用于dartium_Google Chrome_Dart_Dartium - Fatal编程技术网

Google chrome 我的Dart项目没有';即使我将其编译为js,t也可以工作。它只适用于dartium

Google chrome 我的Dart项目没有';即使我将其编译为js,t也可以工作。它只适用于dartium,google-chrome,dart,dartium,Google Chrome,Dart,Dartium,我正在用dart编写一个使用canvas的基本应用程序,它基本上有两个方块,其中一个方块从屏幕的右向左移动,第二个方块在用户按下箭头键时移动 现在的问题是,当我在Dartium尝试它时,效果很好。但如果我尝试在Chrome/Firefox中打开它,我只能看到一个空矩形 Dart编辑器不会显示任何错误,即使我将其编译为javascript代码 但当我查看Chrome Inspect元素的控制台时,有一条错误消息: Uncaught TypeError: Object [object Window]

我正在用dart编写一个使用canvas的基本应用程序,它基本上有两个方块,其中一个方块从屏幕的右向左移动,第二个方块在用户按下箭头键时移动

现在的问题是,当我在Dartium尝试它时,效果很好。但如果我尝试在Chrome/Firefox中打开它,我只能看到一个空矩形

Dart编辑器不会显示任何错误,即使我将其编译为javascript代码

但当我查看Chrome Inspect元素的控制台时,有一条错误消息:

Uncaught TypeError: Object [object Window] has no method 'webkitRequestAnimationFrame$1' 
对该方法的调用如下所示:

  void main() { 
  var maincharacter = new Player(10,10, 70, 70, "red");
  var secondCharacter = new Player(400,250, 50,50, "yellow");
  player = maincharacter;

  sprites = new Set();
  randomnumbergenerator = new Random();
  window.on.keyDown.add(myKeyDownEvent);
  CanvasElement element = query("canvas");  
  context = element.context2d;
  maincharacter.context = context;
  secondCharacter.context = context;
  maincharacter.type = 'player';
  sprites.add(maincharacter);
  sprites.add(secondCharacter);  
  window.webkitRequestAnimationFrame(animate);   
}
在这里:

void animate(num time){
  enemyCreator(time);
  context.clearRect(0,0,400,400);  
  for(final sprite in sprites){
    if(!sprite.isPlayer()) {
      sprite.move(5, 0);
      // sprite.isOutside(0);
      if(!(sprite.posx<0)){ 
        query('#text').text = " Posx: ${sprite.posx.toString()} Length: ${sprites.length}";
        sprite.draw();
      } else {
        query('#text').text = "Destroyed";
        sprites.remove(sprite);
      }      
    } else {
      sprite.draw();
      query('#text').text = " Time: $counter Length: ${sprites.length}";
    }
  }
  window.webkitRequestAnimationFrame(animate);  
}
有什么想法吗

试试看

window.requestAnimationFrame(animate);
相反。

试试看

window.requestAnimationFrame(animate);

相反。

该方法在Dart中称为
requestAnimationFrame()
而不是
webkitRequestAnimationFrame()

int requestAnimationFrame(RequestAnimationFrameCallback回调)

正如约翰所说,试着:

window.requestAnimationFrame(animate);
您可能将Dart的方法与“本机”DOM方法混淆了

Window.prototype.webkitRequestAnimationFrame


在Dart中,您不指定该前缀。

该方法在Dart中称为
requestAnimationFrame()
not
webkitRequestAnimationFrame()

int requestAnimationFrame(RequestAnimationFrameCallback回调)

正如约翰所说,试着:

window.requestAnimationFrame(animate);
您可能将Dart的方法与“本机”DOM方法混淆了

Window.prototype.webkitRequestAnimationFrame


在Dart中,您不指定前缀。

您可以在调用requestAnimationFrame的位置发布Dart代码吗?您可以在调用requestAnimationFrame的位置发布Dart代码吗?