Javascript 我需要阵列中的这些物体以随机速度移动。
这是指向我的github的链接。我需要让allEnemies数组中的物品以随机速度移动。现在他们都在以同样的速度移动。任何关于如何实现这一点的想法都将不胜感激 嗨,我不是JS方面的专家,但像这样的东西应该有用:Javascript 我需要阵列中的这些物体以随机速度移动。,javascript,oop,Javascript,Oop,这是指向我的github的链接。我需要让allEnemies数组中的物品以随机速度移动。现在他们都在以同样的速度移动。任何关于如何实现这一点的想法都将不胜感激 嗨,我不是JS方面的专家,但像这样的东西应该有用: var Enemy = function(x, y) { // Variables applied to each of our instances go here, // we've provided one for you to get started // The image/sp
var Enemy = function(x, y) {
// Variables applied to each of our instances go here,
// we've provided one for you to get started
// The image/sprite for our enemies, this uses
// a helper we've provided to easily load images
this.sprite = 'images/enemy-bug.png';
this.x = x;
this.y = y;
this.speed = Math.floor(Math.random() * MaxSpeedValue) + MinSpeedValue;
}请在问题中包含您要询问的代码,而不是在一个链接中,该链接一旦有人回答您的问题,无疑会过时,从而使这个问题在将来对任何人都没有用处-您的答案的关键字是随机的-公平地说,如果javascript有某种随机数,仅在github上就可以看到此代码的数千个化身