import { AppKernel } from '@scripts/app/AppKernel'; import { IGameInfo } from '@scripts/store/pageSlice/data'; import { _decorator, Component, Node, Sprite } from 'cc'; const { ccclass, property } = _decorator; @ccclass('GameItem') export class GameItem extends Component { @property(Sprite) gameIcon: Sprite; private _gameConfig: IGameInfo; protected onLoad(): void { this.node.on(Node.EventType.TOUCH_END, this.onClick, this); } protected onDestroy(): void { this.node.off(Node.EventType.TOUCH_END, this.onClick, this); } public async initView(game: IGameInfo) { this._gameConfig = game; const resLoader = AppKernel.resources; this.gameIcon.spriteFrame = await resLoader.loadRemoteSp(game.img); } private onClick() { AppKernel.services.lobbyService.openGame(this._gameConfig.id); } }