123456789101112131415161718192021222324252627282930313233343536373839 |
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class MapEnvirment extends cc.Component {
- // @property(cc.Sprite)
- // private bg: cc.Sprite = null;
- // @property(cc.Sprite)
- // private front: cc.Sprite = null;
- @property([cc.Node])
- private bgs: cc.Node[] = [];
- @property([cc.Node])
- private fronts: cc.Node[] = [];
- start () {
- this.changeMap(1);
- }
- changeMap(forceIdx:number=-1) {
- let me = this;
- let idx = Util.random(0, this.bgs.length - 1, true);
- if (forceIdx>=0) {
- idx = forceIdx;
- }
- // return;
- // me.bg.spriteFrame = this.bgs[idx];
- // me.front.spriteFrame = this.fronts[idx];
- // console.error("changeMap:" + idx);
- for (let i = 0; i < this.bgs.length; i++) {
- this.bgs[i].active = i == idx;
- // this.fronts[i].active = i == idx;
- }
- }
- }
|