1
我在学习(开发)一些使用HTML5和TypeScript的游戏。我写这段代码:函数内函数调用
class GameMap {
private sheet: RaphaelPaper;
private tiles: Tile[];
constructor() {
this.tiles = [];
this.sheet = Raphael(document.getElementById('canvas_container'), 500, 500);
}
render() {
var tileWidth = 20;
var tileHeight = 20;
for (var i = 0; i < 30; i++) {
for (var j = 0; j < 30; j++) {
this.tiles.push(new Tile(i, j));
var rectangle = this.sheet.rect(i * tileWidth, j * tileHeight, tileWidth, tileHeight);
rectangle.hover(this.tileMouseOn(), this.tileMouseOut(), rectangle, rectangle);
}
}
}
tileMouseOn() {
this.attr({ 'stroke-width': 1 });
}
tileMouseOut() {
this.attr({ 'stroke-width': 0 });
}
}
问题是用rectangle.hover()
函数。我收到以下错误:
Supplied parameters do not match any signature of call target:
Could not apply type 'Function' to argument 1 which is of type 'void'.
此功能有什么问题?
美丽:)非常感谢。我尝试了一切,除了这个“代表”:P – Fka