我的情况是,我正在利用Box2DWeb开展一场Canvas游戏,因此,我有一个名为Sprite>/em>的班子,为Canvas树立了形象,我现在想创建
class:
Sprite = function (position, dimension, image) {
this.Position = position;
this.Dimension = dimension;
if (image)
this.Image = image;
...
this.Draw = function (g) {
...
}
...
};
而我是在
PhysicsSprite = function(position, dimension, world) {
this.prototype = new Sprite(position, dimension, undefined);
//alert(this.prototype.Position.X)
var body = CreateBody();
this.GetBody = function () { return body; }
this.Draw = function (g) {
...
}
function CreateBody () {
...
}
};
Note the alert (this.prototype.Position.X), which does press me of the status, but if I change the Code to this.Position. X,我有了一个错误,同样,如果我有Physics Sprite>,我必须明确标明原型。
由此,我想,我有的放矢地树立了标本,只是创造了一个叫做prototype<>/code>的财产,并且将这种财产设定为一个新的Sprite。
If someone could help me, and explain what I am doing wrong, that would be much appreciated. I am dyslexic, so I always misspell variables, which is frustrating, so that was the first thing I looked for, but everything looks fine to me.