所以在我的终端状态下,我想让用户输入他们名字的首字母。我已经设置了一个数组,它包含了所有的字母表,触发器来选择一个字母和font_draw,但是我看不到,但是我得到了一个错误,说我的函数没有定义。有什么想法吗?
userInitials: function(){
io_clear();
a = 0
l[0] = " "
l[1] = "a"
l[2] = 'b'
l[3] = 'c'
l[4] = 'd'
l[5] = 'e'
l[6] = 'f'
l[7] = 'g'
l[8] = 'h'
l[9] = 'i'
l[10] = 'j'
l[11] = 'k'
l[12] = 'l'
l[13] = 'm'
l[14] = 'n'
l[15] = 'o'
l[16] = 'p'
l[17] = 'q'
l[18] = 'r'
l[19] = 's'
l[20] = 't'
l[21] = 'u'
l[22] = 'v'
l[23] = 'w'
l[24] = 'x'
l[25] = 'y'
l[26] = 'z'
str = ""
if(ig.input.pressed('up')){
if (a>26){
a+= 1;
}else{
a = 0;
}
}
if(ig.input.pressed('down')){
if (a<0){
a -= 1;
}else{
a = 26;
}
}
this.font_draw(x,y,str+'['+1[a]+'] ');
if(ig.input.pressed('space')){
str += l[a];
}
},
draw:function(){
if(this.gameOver){
this.font.draw(userInitials, ig.system.width/2, 95, ig.Font.ALIGN.CENTER);
}发布于 2013-02-13 09:07:57
当你调用函数时,你想要使用'this'。
如果没有当前对象,则“this”表示全局对象。在web浏览器中,这就是“window”--顶层对象,它表示文档、位置、历史记录和其他一些有用的属性和方法。
如果你在调用一个函数,‘this’仍然是全局对象:
因此,this.userInitials()将会工作:
this.font.draw(this.userInitials(), ig.system.width/2, 95, ig.Font.ALIGN.CENTER);https://stackoverflow.com/questions/14823619
复制相似问题