我試圖通過一組點的像在水平或垂直方向功能不能訪問該對象在javascript
我使用的對象內部的功能,並試圖調用移動cicle的管內同一個對象的另一個功能。
var ParticleGen = function() {
this.pipeBegin = points[pipeIndex];
this.pipeEnds = points[pipeIndex + 1];
this.begin = function(){
var pipeBegin = points[pipeIndex];
var pipeEnds = points[pipeIndex + 1];
nx = pipeBegin.x;
ny = pipeBegin.y;
if(pipeBegin.x == pipeEnds.x && pipeBegin.y >= pipeEnds.y){
if(ny > pipeEnds.y) {
ctx.clearRect(0, 0, w, h);
drawCircle(nx, ny);
ny--;
nx = nx;
}else if(ny == pipeEnds.y){
cancelAnimationFrame(animloop);
this.callBegin();
}
requestAnimFrame(animloop);
}
animloop();
}
this.callBegin = function(){
if(pipeIndex <= 3){
pipeIndex++;
}
this.begin();
}
};
但它會引發錯誤。
Uncaught TypeError: Object [object global] has no method 'callBegin'
的代碼片斷可以看出here
謝謝
哪裏是你的callBegin()函數? –