Cocos2d在Chrome和Firefox中进行文本对齐

时间:2017-01-09 07:33:09

标签: javascript html5-canvas cocos2d-x cocos2d-js

这是它在chrome和mozilla中的外观

我正在使用cocos2dx-3.10

我已使用此代码

var TestLayer = cc.LayerColor.extend({
    ctor: function () {
        this._super(cc.color(255, 255, 255));


        var lineUp = new cc.DrawNode();
        lineUp.drawSegment(cc.p(0, 0), cc.p(200, 0), 0.5, cc.color(80, 80, 80));
        lineUp.setPosition(cc.p(this.width / 2 - 100, this.height / 2 + 13));
        this.addChild(lineUp);

        var lineDown = new cc.DrawNode();
        lineDown.drawSegment(cc.p(0, 0), cc.p(200, 0), 0.5, cc.color(80, 80, 80));
        lineDown.setPosition(cc.p(this.width / 2 - 100, this.height / 2 - 17));
        this.addChild(lineDown);

        var label = new cc.LabelTTF("Lorem Ipsum", "Arial", 30);
        label.setColor(cc.color(0, 0, 0));
        label.setPosition(cc.p(this.width / 2, this.height / 2));
        this.addChild(label);

    }
});

Click here to see screenshot - Left Side Image In - Chrome version Version 55.0.2883.87 m (64-bit) and Right Side Image In - Mozilla Firefox Version 50.1.0

0 个答案:

没有答案