我在 game.js 文件的顶部(来自 game.ts 编译)得到了这个定义语句:
define(["require", "exports", "GameObjects"], function(require, exports, __GameObjects__) {
var GameObjects = __GameObjects__;
$(document).ready(function () {
var game = new Game();
$(document).keydown(game.onKeyDown);
$(document).keyup(game.onKeyUp);
$(document).keyup(game.onKeyUp);
});
function collides(a, b) {
和这个错误: Uncaught TypeError: undefined is not a function
从这个页面:
<head>
<title>Space Demo</title>
<link href="/stylesheets/screen.css" media="all" rel="stylesheet" type="text/css" />
<script language="javascript" src="javascripts/require.js" type="text/javascript" data-main="ts/game.js"> </script>
<script language="javascript" src="javascripts/jquery-1.8.2.min.js" type="text/javascript"> </script>
</head>
有任何想法吗?
编辑_ _ __ _ __ _ __ _ __ _ __ _
游戏类在game.js文件中
类游戏{
// canvas: JQuery;
CANVAS_WIDTH: number = 400;
CANVAS_HEIGHT: number = 400;
FPS: number = 30;
enemies = [];
playerBullets: Array = new Array[40];
player: GameObjects.GameObjects.Player;
canvas: HTMLCanvasElement = <HTMLCanvasElement> document.getElementById('canvas');
context2D: CanvasRenderingContext2D;
constructor () {
// this.canvas = canvas;
this.context2D = this.canvas.getContext("2d");
this.canvas.width = this.CANVAS_WIDTH;
this.canvas.height = this.CANVAS_HEIGHT;
this.initGame();
}