| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /**
- * @description 更多游戏按钮
- * @author kaka
- */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class BtnMoreGame extends cc.Component {
- @property(cc.Sprite)
- sp_moregame: cc.Sprite = null;
- @property(cc.Label)
- lab_moregame: cc.Label = null;
- update() {
- if (gData.moreGame.init_moreGameList) {
- this.setMoreGameSp(gData.moreGame.moreGameList.normal);
- }
- }
- lateUpdate() {
- gData.moreGame.init_moreGameList = false;
- }
- /** 设置更多游戏图片 */
- setMoreGameSp(arr) {
- let len = arr.length
- let index = mk.math.random(0, len - 1)
- let data = arr[index]
- this.showMoreGameSp(data)
- this.schedule(() => {
- index++
- index = (index % len)
- // LogUtil.logV('setMoreGameSp ', 'index ' + index)
- data = arr[index]
- this.showMoreGameSp(data)
- }, 10)
- }
- /** 切换图片 */
- showMoreGameSp(data) {
- //pc不加载,加载会报错
- if (cc.sys.os != cc.sys.OS_WINDOWS) {
- cc.loader.load(data.icon, (err, res) => {
- if (err) {
- console.log('err:', err);
- return;
- }
- if (this.sp_moregame) {
- let tex: cc.Texture2D = res as cc.Texture2D;
- this.sp_moregame.spriteFrame = new cc.SpriteFrame(tex);
- }
- })
- }
- this.lab_moregame.string = data.title
- }
- }
|