91 lines
2.6 KiB
TypeScript
91 lines
2.6 KiB
TypeScript
/**
|
|
* 游戏场景
|
|
*/
|
|
|
|
import AudioManager from "../Tools/AudioManager";
|
|
import { GameType } from "../Tools/Define";
|
|
import GameResMgr, { soundName, uiPreName } from "../Tools/GameResMgr";
|
|
import PlayData from "../Tools/PlayData";
|
|
//import AdsApiMgr from "../Tools/Sdk/ads/AdsApiMgr";
|
|
//import gameNetWorkControl from "../Tools/gameNetWorkControl";
|
|
import setPanelSc from "./LevelUpGame/setPanelSc";
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class GameSceneSc extends cc.Component {
|
|
|
|
@property(cc.Node)
|
|
gamenode:cc.Node = null
|
|
|
|
@property(cc.Node)
|
|
uinode:cc.Node = null
|
|
|
|
@property(cc.Sprite)
|
|
bg:cc.Sprite = null
|
|
|
|
@property([cc.SpriteFrame])
|
|
bgsp:cc.SpriteFrame[] = []
|
|
|
|
onLoad () {
|
|
var self = this
|
|
cc.game.on('addnewgame', ()=>{
|
|
let newnode = null
|
|
if(PlayData.Instance.gameType == GameType.challenge){
|
|
newnode = cc.instantiate(GameResMgr.Instance.uiPre[uiPreName.challengeGameNode])
|
|
}else if(PlayData.Instance.gameType == GameType.normal){
|
|
newnode = cc.instantiate(GameResMgr.Instance.uiPre[uiPreName.gameNode])
|
|
}
|
|
|
|
newnode.opacity = 0
|
|
newnode.x = 1000
|
|
newnode.parent = self.gamenode
|
|
|
|
cc.tween(newnode)
|
|
.to(0.5, {x:0,opacity:255})
|
|
.start()
|
|
})
|
|
|
|
self.bg.spriteFrame = self.bgsp[PlayData.Instance.gameType]
|
|
|
|
cc.game.emit('addnewgame')
|
|
|
|
let newtili = cc.instantiate(GameResMgr.Instance.uiPre[uiPreName.top_tili])
|
|
let wiget = newtili.getComponent(cc.Widget)
|
|
wiget.left = -400
|
|
newtili.parent = this.uinode
|
|
|
|
// if(gameNetWorkControl.Instance.getChapState()){
|
|
// this.schedule(()=>{
|
|
// AdsApiMgr.Instance.chaPingAds_Show()
|
|
// }, 120, 60, 60)
|
|
// }
|
|
}
|
|
|
|
start () {
|
|
AudioManager.playMusic(soundName.bgSound1)
|
|
cc.find('topnode0', this.uinode).active = PlayData.Instance.gameType == GameType.normal
|
|
cc.find('topnode1', this.uinode).active = PlayData.Instance.gameType == GameType.challenge
|
|
}
|
|
|
|
/**
|
|
* 按钮点击事件
|
|
* @param t
|
|
* @param e
|
|
*/
|
|
btnClickCallBack(t, e){
|
|
if(e == 'home'){
|
|
cc.director.loadScene('StartScene')
|
|
}else if(e == 'set'){
|
|
let newnode = cc.instantiate(GameResMgr.Instance.uiPre[uiPreName.setPanel])
|
|
newnode.parent = this.uinode
|
|
let sc = newnode.getComponent(setPanelSc)
|
|
sc.showType(1)
|
|
}
|
|
}
|
|
|
|
update (dt) {
|
|
|
|
}
|
|
}
|