我試圖實例化一個類是這樣的:試圖實例化一個動畫類,收到「對象不是一個函數」
var drawCrash = new DrawCrash;
但我得到一個類型錯誤:對象不是一個函數。
我定義的類這樣的 -
var DrawCrash = {
//Private variables
canvas : ge1doot.Canvas(),
particles: "",
nbrParticles : 160,
speed : 6,
strength : .4,
radius : 4,
perspective : 0.5,
ang : null,
CosOrSin1 : null,
CosOrSin2 : null,
enum : {
\t Wobble : "wobble",
\t Twirl : "twirl"
},
setDrawing : function (type) {
\t if (type === this.enum.Twirl){
\t Blah blah blah
\t \t this.cosOrSin2 = Math.sin;
\t } else if (type === this.enun.Wobble){
\t \t Blah blah blah
\t } else {alert("Wrong enum for DrawCrash");}
},
startDrawing : function() {
blah blah blah
}
}
有什麼不對的語法?
呀,DrawCrash不是一個函數的ñ,所以你不能新的。 –