こちらの情報で解決しました
enchant.js でテキストラベルを中央に表示する - くろの雑記帳
http://kurochan-note.hatenablog.jp/entry/2013/01/28/000734
Label の _boundWidth からラベルの横幅を取得できるようです。
var button = new Group();
var background = new Sprite();
background.image = game.assets['/mucha/button.png'];
background.width = background.image.width;
background.height = background.image.height;
button.addChild(background);
var label = new Label();
label.text = config.button;
label.color = 'white';
label.font = '30px sans-serif';
label.x = (background.width - label._boundWidth) / 2;
label.y = (background.height - 30) / 2;
button.addChild(label);
button.width = background.width;
button.height = background.height;
button.x = (messageWindow.width - button.width) / 2;
button.y = 350;
button.addEventListener('touchstart', function() {
game.currentScene.removeChild(messageWindow);
config.callback.call(game);
});
messageWindow.addChild(button);

0 件のコメント:
コメントを投稿