在Typescript中扩展Spride类(Pixi.js)
我正在尝试在typescript项目中扩展Pixi.Spride类。(我添加了一些其他属性)。 但当我实例化我的新对象时,我得到了: 未捕获类型错误:未定义不是函数 这是我的密码:在Typescript中扩展Spride类(Pixi.js),typescript,Typescript,我正在尝试在typescript项目中扩展Pixi.Spride类。(我添加了一些其他属性)。 但当我实例化我的新对象时,我得到了: 未捕获类型错误:未定义不是函数 这是我的密码: ///<reference path="../lib/pixi.d.ts" /> enter code here // Module module test { // Class export class Card extends PIXI.Sprite {
///<reference path="../lib/pixi.d.ts" />
enter code here
// Module
module test {
// Class
export class Card extends PIXI.Sprite {
public name: string;
public value : number;
constructor(arg : any) {
super(arg);
}
}
}
and
for instantiation i did this :
var cardTexture = PIXI.Texture.fromImage("img/aa.png");
c= new Card (cardTexture );
///
在这里输入代码
//模块
模块测试{
//阶级
导出类卡扩展PIXI.Sprite{
公共名称:字符串;
公共价值:数字;
构造函数(arg:any){
超级(arg);
}
}
}
及
对于实例化,我做了以下操作:
var cardTexture=PIXI.Texture.fromImage(“img/aa.png”);
c=新卡(cardTexture);
未捕获类型错误:未定义不是函数
这是一个运行时错误,清楚地表明您认为由浏览器加载的JS实际上不存在。检查脚本标记(注意:顺序很重要)或使用amd/或commonjs()