socket.ioとcocos2d-html5が機能するようになりました。新しいクライアントが接続するたびに、新しいLabelTTFを画面に表示したいと思います。アプリケーションの開始時に、_tilemaplayerに格納されている子としてTilemaplayerを使用してメインレイヤーを作成します。
メインレイヤーでは、onEnterに次のコードがあります。
var tilemap = new TilemapLayer();
this._tilemaplayer = tilemap;
this.addChild(tilemap);
socket = io.connect('hostname:port');
socket.on('connect', function(){
socket.emit('setName', {name: 'Testname'})
})
socket.on('newClient', function(data){
var testLabel = cc.LabelTTF.create(data.name, "Arial", 32);
this._tilemaplayer.addChild(testLabel);
})
this._tilemaplayerが定義されていないというエラーが表示されるのはなぜですか?メインレイヤーの他の機能でアクセスできますが、ここにアクセスしてみませんか?