function component(width, height, source, x, y) {
this.image = new Image();
this.image.src = source;
this.width = width;
this.height = height;
this.x = x;
this.y = y;
this.update = function() {
ctx = myGameArea.context;
ctx.drawImage(this.image,
this.x,
this.y,
this.width, this.height);
}
this.newPos = function(a, b, image, h) {
this.x = a;
this.y = b;
this.image.src = image;
this.height = h;
}
}
コンポーネントでクリックが行われたときに関数を呼び出すにはどうすればよいですか? クリックの座標を記録し、コンポーネントのものと比較するだけでいいですか?コンポーネントをクリックして関数を呼び出す方法は?