OK Я новичок в кодировании и попытался сделать небольшой клон. как-то этот объект исчезает, когда он попадает в нижнюю часть элемента холста.Почему этот объект исчезает?
Вот мой код:
var padle = {
x: 0,
y: 150,
w: 20,
h: 50,
// Add vx and vy properties here:
vx: 0,
vy: 100,
ax: 0,
ay: 0,
color: "#FAFAFA",
draw: function() {
ctx.beginPath();
ctx.fillRect(this.x, this.y, this.w, this.h);
ctx.fillStyle = this.color;
ctx.fill();
},
update: function() {
// Update the particle's position
this.vx += this.ax/FPS;
this.vy += this.ay/FPS;
this.x += this.vx/FPS;
this.y += this.vy/FPS;
if (this.x < 0) {
this.x = 0;
this.vx = -this.vx;
}
if (this.x > canvas.width) {
this.x = canvas.width;
this.vx = -this.vx;
}
if (this.y < 0) {
this.y = 0;
this.vy = -this.vy;
}
if ((this.y + this.h)> canvas.height) {
this.y = canvas.height;
this.vy = -this.vy;
}
}
};`
, что случилось? Я действительно не понимаю.
Можете ли вы [воспроизвести проблему] (http://jsfiddle.net)? – undefined