| 123456789101112131415161718192021222324252627282930313233 |
- import { AppKernel } from '@scripts/app/AppKernel';
- import { IGameInfo } from '@scripts/store/pageSlice/data';
- import { addBtnClick, removeBtnClick } from '@scripts/utils/UIHelper';
- 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 {
- addBtnClick(this.node, this.onClick, this);
- }
- protected onDestroy(): void {
- removeBtnClick(this.node, 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);
- }
- }
|