优化GameComponent

This commit is contained in:
donggang
2024-05-30 15:21:30 +08:00
parent 08f5867a9a
commit ea81461496
2 changed files with 4 additions and 7 deletions

View File

@@ -108,7 +108,7 @@ export class Root extends Component {
game.on(Game.EVENT_HIDE, this.onHide, this);
// 游戏尺寸修改事件
var c_gui = this.gui.addComponent(GUI)!;
// var c_gui = this.gui.addComponent(GUI)!;
if (sys.isMobile == false) {
screen.on("window-resize", () => {
oops.message.dispatchEvent(EventMessage.GAME_RESIZE);

View File

@@ -225,16 +225,13 @@ export class GameComponent extends Component {
/**
* 批量设置当前界面按钮事件
* @example
* 注按钮节点Label1、Label2必须绑定ButtonSimple、ButtonEffect等类型的按钮组件才会生效,方法名必须与节点名一致
* this.setButton("Label1", "Label2");
* 注按钮节点Label1、Label2必须绑定UIButton等类型的按钮组件才会生效方法名必须与节点名一致
* this.setButton();
*
* Label1(event: EventTouch) { console.log(event.target.name); }
* Label2(event: EventTouch) { console.log(event.target.name); }
*/
protected setButton(...args: string[]) {
this.setButtonList(args);
}
protected setButtonList(args: string[]) {
protected setButton() {
// 自定义按钮批量绑定触摸事件
this.node.on(Node.EventType.TOUCH_END, (event: EventTouch) => {
var self: any = this;