49 lines
1.3 KiB
TypeScript
49 lines
1.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;
|
|
|
|
@ccclass
|
|
export default class HelloWorld extends cc.Component {
|
|
|
|
@property(cc.Label)
|
|
public Label: cc.Label = null;
|
|
|
|
@property
|
|
public Text: string = 'hello';
|
|
|
|
@property(cc.Button)
|
|
public Btn: cc.Button = null;
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
protected onLoad() {
|
|
let self = this;
|
|
this.Label.string = this.Text;
|
|
window["eventBus"].on('SendContent', (content: string) => {
|
|
self.Label.string = content;
|
|
})
|
|
}
|
|
|
|
public onClickBtn() {
|
|
window["eventBus"].emit("Alert", "hello");
|
|
// let url: string = window.location.search;
|
|
// let URLscheme: any[] = [];
|
|
// if (url.indexOf("?") !== -1) {
|
|
// let str = url.substring(1);
|
|
// let strs = str.split("&");
|
|
// for (let i = 0; i < strs.length; i++) {
|
|
// URLscheme[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
|
|
// }
|
|
// }
|
|
// if (URLscheme["host"]) {
|
|
// opener?.window.parent.postMessage({ data: "hello" }, URLscheme["host"]);
|
|
// window.close();
|
|
// }
|
|
}
|
|
}
|