问题描述
我正在尝试为我的新平台游戏制作碰撞函数,但在制作碰撞原型函数时遇到错误。
platforms = [];
var newPlatform = function(x,y) {
this.x = x,this.y = y,this.width = 50,this.height
}
var platform1 = new newPlatform(10,100);
var platform2 = new newPlatform(50,50);
platforms.push(platform1);
platforms.push(platform2);
var player = {
x:100,y:305,width:80,height:120,veLocity_y:4
}
platforms.prototype.collision = function(player) {
return (this.x < player.x + player.width && this.x + this.width > player.x && this.y
< player.y + player.height && this.y + this.height > player.y);
}
for (let i = 0; i < platforms.length; i++) {
if (platforms[i].collision(player)) {
player.veLocity_y = 0 ;
}
}
这给出了一个错误,内容为“无法设置未定义的属性'碰撞'”有谁知道如何解决这个问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)