【发布时间】:2016-10-29 17:07:18
【问题描述】:
我正在尝试根据键动态调用绘图函数。
当我注销 renderFunctions 时,它显示为空 Object {}。
我希望这些功能包含在“ship”和“ball”键的内部。
class Render {
static renderFunctions() {
return {
'ship': this.drawShip,
'ball': this.drawBall
};
}
static render(key, ls, context, portal) {
let renderFns = this.renderFunctions();
console.log(renderFns);
}
static drawShip(ctx, p, t) {
p.drawRect(ctx, t.x - 5, t.y - 100, 10, 100, t.teamColor);
}
static drawBall(ctx, p, t) {
ctx.arc(t.x, t.y, 7, 0, 2 * Math.PI, false);
ctx.fillStyle = t.teamColor;
ctx.fill();
}
}
为什么我的功能没有显示?
【问题讨论】:
标签: javascript static ecmascript-6