Commit 7e74769f authored by LMZ's avatar LMZ

feat: 星星位置调整

parent 731980ed
......@@ -28,20 +28,38 @@ cc.Class({
start() {},
setStarCount() {
let disH = 80;
// let disScale = 1;
// if (this._count > 5) {
// disH = (400 / gArr.length);
// disScale = 5 / gArr.length;
// let disH = 80;
// // let disScale = 1;
// // if (this._count > 5) {
// // disH = (400 / gArr.length);
// // disScale = 5 / gArr.length;
// // }
// for (let i = 0; i < this._count; i++) {
// const starBg = this.getSprNode("img/star_bg");
// starBg.y = -i * disH;
// this.node.addChild(starBg);
// }
for (let i = 0; i < this._count; i++) {
const starBg = this.getSprNode("img/star_bg");
starBg.y = -i * disH;
this.node.addChild(starBg);
let length = this._count;
const layout = cc.find('layout', this.node);
layout.height = this._bgHeight - 100;
const paddingY = layout.getComponent(cc.Layout).spacingY;
for (let i = 0; i < length; i++) {
const starBase = this.getSprNode("img/star_bg");
starBase.name = `starBase_${i}`;
starBase.scale = this.between(0.5, (layout.height / length - paddingY) / starBase.height, 1);
starBase.parent = layout;
}
this.currentStarIdx = 0;
},
getSprNode(resName) {
const sf = cc.find(resName, this.node).getComponent(cc.Sprite).spriteFrame;
const node = new cc.Node();
......@@ -168,5 +186,10 @@ cc.Class({
// playAudio(this.bigStarClip);
},
between(a, b, c) {
return [a, b, c].sort()[1];
},
// update (dt) {},
});
This diff is collapsed.
......@@ -319,7 +319,7 @@ cc.Class({
const starNode = cc.find("Canvas/starNode");
const script = starNode.getComponent("star");
script.bgHeight = this.canvas.height;
script.count = 12;
script.count = 3;
},
bigStarArr: null,
......
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