0
私はJavaScriptの単純な関数で奇妙な動作をしています。私は行列で書いていますが、もう一度読むと変更が見えません。誰かがなぜ私を説明できますか?ここ コードである: ''JavaScriptの変数が書かれていない
this.map = [
'## ### ##',
'# # #',
'# # . # #',
'# ## # #',
'## # #',
'#*# ## ##',
' ## ',
'#########'
];
this.check_collision = function (x, y) {
var l = Math.floor (y/this.tile_size);
var c = Math.floor (x/this.tile_size);
if (this.map[ l ] != undefined) {
if (this.map[ l ][ c ] != undefined) {
if (this.map[ l ][ c ] == '#') {
return true;
}
else if (this.map[ l ][ c ] == '.' || this.map[ l ][ c ] == '*') {
this.map[ l ][ c ] = ' ';
console.debug ("'" + this.map[ l ][ c ] + "'");
}
}
}
return false;
};
console.debug()印刷または '*'のようになりますが、上の行にchar ''という文字を書きます。
'console.debug'ではなく' alert'をテストします。それでも同じ結果が得られますか? –
はい。同じ結果 –
[サンプルコード](http://sscce.org/)は不完全です。実際に 'this.map [l]'には何が格納されていますか?文字列の場合、文字列は不変です。 – outis