Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lettas committed Dec 26, 2013
1 parent 2ce34f8 commit 483a1e3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions public/js/src/beamQuest.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,34 @@ var BeamQuestWorld = cc.Layer.extend({
if (! cc.Director.getInstance().isDisplayStats()) {
return;
}

// ping始める
this.ping_ = new bq.Ping(bq.Socket.getInstance().socket, 300);
var interval = 300;
this.ping_ = new bq.Ping(bq.Socket.getInstance().socket, interval);
this.ping_.start();

// 表示用テキストを作る
var pingText = function() {
return "ping: " + this.ping_.getRoundTripTime();
}.bind(this);

// ラベル作る
var pingLabel = bq.Label.createWithShadow(pingText(), 16);
var fontSize = 16;
var pingLabel = bq.Label.createWithShadow(pingText(), fontSize);
pingLabel.setAnchorPoint(cc.p(0, 1.0));

var size = cc.Director.getInstance().getWinSize();
// 表示位置
var margin = 5;
pingLabel.setPosition(cc.p(margin, size.height - margin));
var winSize = cc.Director.getInstance().getWinSize();
pingLabel.setPosition(cc.p(margin, winSize.height - margin));

// ラベル更新する
// 表示内容更新処理
pingLabel.schedule(function() {
pingLabel.setString(pingText());
}.bind(this));
});

this.addChild(pingLabel, 10000, bq.config.tags.DEBUG_PING);
var zIndex = 10000;
this.addChild(pingLabel, zIndex, bq.config.tags.DEBUG_PING);
}
});

Expand Down

0 comments on commit 483a1e3

Please sign in to comment.