所以,我正在制作一个小型的Web应用程序,以便在使用画布时变得更好,但是我被卡住了.我想要一个旋转的n边多边形(线条图已经有效).游戏循环遍历网格数组(网格上的每个点都包含Point()对象的子类),并在每个上调用tick()方法.一切正常,直到它碰到一个ShapePoint()对象(中间的鼠标放在画布上).ShapePoint的tick()方法在某种程度上是一个无限循环.如果你把一个console.log("hi")放在里面,它会给你大约2000条"hi"消息,所以它正在工作(理论上).有趣的是,尽管它正在循环通过stoke(),但没有任何事情发生!
//################################################################
// THIS IS THE PROBLEM CLASS.
// So pretty much, when the game loop calls the tick() funciton
// of ANY ShapePoint object, everything hangs. The game is still
// looping through the ENTIRE tick() function (put console.log()
// functions in and you'll see what I mean) continually, but the
// effects it is supposed to display aren't shown.
//
//################################################################
function ShapePoint(x, y, sides) {
//position variable
this.positionOnCanvas = [x, y];
//number of sides
this.N = sides; …Run Code Online (Sandbox Code Playgroud)