Commit f99af5c5 authored by 范雪寒's avatar 范雪寒

feat: 屏幕适配

parent 9adff6a1
This diff is collapsed.
...@@ -84,7 +84,6 @@ cc.Class({ ...@@ -84,7 +84,6 @@ cc.Class({
this.initView(); this.initView();
this.initListener(); this.initListener();
this.showLetterAnimation(); this.showLetterAnimation();
this.startEditMode(); this.startEditMode();
}, },
...@@ -109,7 +108,7 @@ cc.Class({ ...@@ -109,7 +108,7 @@ cc.Class({
letter: null, letter: null,
initView() { initView() {
// this.debugMode = true; // this.debugMode = true;
this.setLetter(this.data.letter); this.setLetter(this.data.letter);
}, },
setLetter(letter) { setLetter(letter) {
...@@ -118,6 +117,26 @@ cc.Class({ ...@@ -118,6 +117,26 @@ cc.Class({
this.updateLetterBtnLabel(); this.updateLetterBtnLabel();
this.addDrawLetter(this.letter); this.addDrawLetter(this.letter);
cc.find('Canvas').on('size-changed', () => {
this.onSizeChanged();
});
this.onSizeChanged();
},
onSizeChanged() {
this.node.getComponent(cc.Widget).updateAlignment();
const currentSize = { width: this.node.width, height: this.node.height };
console.log('currentSize = ' + JSON.stringify(currentSize));
const frameSize = cc.view.getFrameSize();
console.log('frameSize = ' + JSON.stringify(frameSize));
const designSize = cc.view.getDesignResolutionSize();
console.log('designSize = ' + JSON.stringify(designSize));
const letterBg = cc.find('Canvas/bg/Img_letter_bg');
const scale = (designSize.width / designSize.height) / (frameSize.width / frameSize.height);
letterBg.scale = Math.min(scale, 1);
}, },
updateLetterBtnLabel() { updateLetterBtnLabel() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment