123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
- import { ddz_tip_item } from './ddz_tip_item';
- const { ccclass, property } = _decorator;
- @ccclass('tip_layer')
- export class tip_layer extends Component {
- @property(Prefab) itemPrefab:Prefab;
- @property(Node) content:Node;
- @property(Node) btn_close:Node;
- private card_list = {3: '3', 4: '4', 5: '5', 6: '6', 7: '7',
- 8: '8', 9: '9', 10: '10', 11: 'J', 12: 'Q',
- 13: 'K', 14: 'A', 17: '2', 20: '小王', 30: '大王','P':"过"};
- public initView(answer_content){
- let list = answer_content.split(';')
- this.content.removeAllChildren()
- for (let index = 0; index < list.length; index++) {
- const str = `第${index+1}步:${this.getCardStr(list[index])}`;
- let item = instantiate(this.itemPrefab)
- item.parent = this.content;
- item.getComponent(ddz_tip_item).initView(str)
- }
- this.btn_close.off(Node.EventType.TOUCH_END)
- this.btn_close.on(Node.EventType.TOUCH_END,()=>{
- this.node.active = false;
- })
-
- }
- getCardStr(str_list){
- let list = str_list.split(',')
- let temp = []
- for (let index = 0; index < list.length; index++) {
- const element = list[index];
- if(element==="P"){
- temp.push(this.card_list[element])
- }else{
- temp.push(this.card_list[parseInt(element)])
- }
- }
- return temp.toString()
- }
- }
|