You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
3.3 KiB
TypeScript
141 lines
3.3 KiB
TypeScript
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
const {ccclass, property, } = cc._decorator;
|
|
|
|
|
|
|
|
enum moduleState {
|
|
"INIT",
|
|
|
|
};
|
|
|
|
@ccclass("gameMY")
|
|
export class gameMY extends cc.Component {
|
|
|
|
@property
|
|
columnCount = 5;
|
|
|
|
@property
|
|
itemSize = 240;
|
|
|
|
@property(cc.Label)
|
|
betString: cc.Label = null;
|
|
|
|
@property(cc.Label)
|
|
bigFrameString: cc.Label = null;
|
|
|
|
@property(cc.Label)
|
|
balanceString: cc.Label = null;
|
|
|
|
|
|
@property({type: cc.Prefab})
|
|
columnPrefab: cc.Prefab | null = null;
|
|
|
|
@property(cc.Node)
|
|
slotBoard: cc.Node = null;
|
|
|
|
|
|
|
|
|
|
private betNumber: number;
|
|
private balanceNumber: number;
|
|
private bigFrameNumber: number;
|
|
|
|
// item 圖片資源存放區
|
|
itemNameMapping = {
|
|
'item_01':1, 'item_02':2, 'item_03':3, 'item_04':4, 'item_9':5,
|
|
'item_10':6, 'item_j':7, 'item_k':8, 'item_q':9, 'item_a':10,
|
|
'item_scatter':51, 'item_wild':52
|
|
} as const;
|
|
|
|
item_spriteFrame = {};
|
|
itemBlur_spriteFrame = {};
|
|
|
|
init_Complete:boolean = false
|
|
|
|
protected onLoad () {
|
|
|
|
|
|
this.unitTestInit(); // for engineer use
|
|
|
|
// 讀取 item 圖片資源
|
|
cc.resources.loadDir('item',cc.SpriteFrame, (err: any, sF) => {
|
|
sF.forEach( (eachSpriteFrame)=>{
|
|
this.item_spriteFrame[ this.itemNameMapping[eachSpriteFrame.name] ] = eachSpriteFrame
|
|
})
|
|
} );
|
|
cc.resources.loadDir('item_blur',cc.SpriteFrame, (err: any, sF) => {
|
|
sF.forEach( (eachSpriteFrame)=>{
|
|
this.itemBlur_spriteFrame[ this.itemNameMapping[eachSpriteFrame.name] ] = eachSpriteFrame
|
|
})
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
protected start () {
|
|
this.betNumber = 50;
|
|
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab) )
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab) )
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab) )
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab) )
|
|
|
|
}
|
|
|
|
protected update (dt) {
|
|
|
|
if(!this.init_Complete){
|
|
// 完成圖片載入再啟動 column
|
|
if((Object.keys(this.item_spriteFrame).length === 12)){
|
|
for(let i=0;i<=5;i++){
|
|
this.slotBoard.children[i].getComponent('columnControl').gameModule = this.node;
|
|
this.slotBoard.children[i].active = true;
|
|
this.init_Complete=true;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
onBetBtnClick(e: cc.Event.EventTouch): void {
|
|
// let a = e.getCurrentTarget().name
|
|
// cc.log(a)
|
|
if(e.getCurrentTarget().name == 'btn_plus'){
|
|
this.betNumber += 50;
|
|
}
|
|
else{
|
|
this.betNumber -= 50;
|
|
}
|
|
this.betString.string = "" + this.betNumber
|
|
}
|
|
|
|
|
|
onSpinBtnClick():void {
|
|
|
|
|
|
|
|
|
|
cc.log("nothing");
|
|
|
|
}
|
|
|
|
unitTestInit():void {
|
|
// for unitTest 1
|
|
this.node.on('Bob', (arg1)=>{
|
|
cc.log("columnControl Recieve Bob say " + arg1)
|
|
}, this)
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|