让精灵转向鼠标

时间:2016-12-14 23:13:56

标签: javascript p5.js

我正在使用p5.play.js制作项目符号,但出于某种原因,当这段代码运行时,子弹只会保持不动并且不会移动到任何地方......感谢你的帮助!

function mousePressed() {
  var bullet = createSprite(player.position.x, player.position.y);
  
  bullet.addImage(bulletImg);
  bullet.life = 120;
  bullet.scale = screenSize/3;
  
  var dx = mouseX - bullet.postion.x;
  var dy = mouseY - bullet.postion.y;
  var angle = Math.atan2(dy, dx);

  bullets.add(bullet);
  bullet.setSpeed(7, angle);
 
}

0 个答案:

没有答案