@cloudgaming/paas-web / Exports / Game
Class: Game
Hierarchy
TypedEventEmitter
<IGameClientEvents
,this
>
↳ Game
Table of contents
Constructors
Properties
Methods
- addListener
- disconnect
- emit
- eventNames
- getMaxListeners
- listenerCount
- listeners
- off
- on
- once
- pauseKeyboardAndMouse
- prependListener
- prependOnceListener
- rawListeners
- removeAllListeners
- removeListener
- requestFullScreen
- resumeKeyboardAndMouse
- setMaxListeners
- setMouseMode
Constructors
constructor
• new Game(endpoint?
, channelId?
, bsUrl?
)
构建云游戏实例
Parameters
Name | Type | Description |
---|---|---|
endpoint? |
string |
服务地址,默认无需传入 |
channelId? |
string |
渠道号,默认无需传入 |
bsUrl? |
string |
后端服务地址,默认无需传入 |
Overrides
(EventEmitter as new (options?: any) =\> TypedEmitter<IGameClientEvents\>).constructor
Defined in
lib/Game.ts:124
Properties
checkQueue
• Readonly
checkQueue: (getAuthToken
: (session
: string
) => Promise
<string
>, gameName?
: string
, spec?
: string
, gameArgs?
: Record
<string
, string
>) => Promise
<Object
>(options
: CheckQueueOptions
) => Promise
<Object
>
Type declaration
▸ (getAuthToken
, gameName?
, spec?
, gameArgs?
): Promise
<Object
>
检查是否需要排队
Parameters
Name | Type |
---|---|
getAuthToken |
(session : string ) => Promise <string > |
gameName? |
string |
spec? |
string |
gameArgs? |
Record <string , string > |
Returns
Promise
<Object
>
▸ (options
): Promise
<Object
>
检查是否需要排队
Parameters
Name | Type |
---|---|
options |
CheckQueueOptions |
Returns
Promise
<Object
>
Defined in
lib/Game.ts:289
grade
• grade: number
Defined in
lib/Game.ts:107
jy
• jy: any
Defined in
lib/Game.ts:103
rpc
• rpc: Client
Defined in
lib/Game.ts:102
setDisplayGrade
• Readonly
setDisplayGrade: (displayGrade
: number
) => Promise
<void
>
Type declaration
▸ (displayGrade
): Promise
<void
>
Parameters
Name | Type |
---|---|
displayGrade |
number |
Returns
Promise
<void
>
Defined in
lib/Game.ts:521
startGame
• Readonly
startGame: (videoId
: string
, getStartToken
: (session
: string
) => Promise
<string
>, getRenewToken
: (session
: string
, lastDeadline
: number
) => Promise
<string
>, progressCallback
: (progress
: number
) => void
, playCallback?
: (video
: HTMLVideoElement
) => void
) => Promise
<void
>
开始游戏
Type declaration
▸ (videoId
, getStartToken
, getRenewToken
, progressCallback
, playCallback?
): Promise
<void
>
开始游戏
Parameters
Name | Type | Description |
---|---|---|
videoId |
string |
视频标签 id |
getStartToken |
(session : string ) => Promise <string > |
|
getRenewToken |
(session : string , lastDeadline : number ) => Promise <string > |
|
progressCallback |
(progress : number ) => void |
进度回调 |
playCallback? |
(video : HTMLVideoElement ) => void |
可以播放的回调,传入后 SDK 不对 video 做 play 处理 |
Returns
Promise
<void
>
Defined in
lib/Game.ts:462
state
• state: GameClientState
Defined in
lib/Game.ts:116
stopGame
• Readonly
stopGame: () => Promise
<boolean
>
Type declaration
▸ (): Promise
<boolean
>
Returns
Promise
<boolean
>
Defined in
lib/Game.ts:512
Methods
addListener
▸ addListener<E
>(event
, listener
): Game
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
listener |
IGameClientEvents [E ] |
Returns
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).addListener
Defined in
node_modules/typed-emitter/index.d.ts:24
disconnect
▸ disconnect(): void
停止并断开云游戏的连接
Returns
void
void
Defined in
lib/Game.ts:183
emit
▸ emit<E
>(event
, ...args
): boolean
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
...args |
Arguments <IGameClientEvents [E ]> |
Returns
boolean
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).emit
Defined in
node_modules/typed-emitter/index.d.ts:34
eventNames
▸ eventNames(): (string
| symbol
)[]
Returns
(string
| symbol
)[]
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).eventNames
Defined in
node_modules/typed-emitter/index.d.ts:35
getMaxListeners
▸ getMaxListeners(): number
Returns
number
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).getMaxListeners
Defined in
node_modules/typed-emitter/index.d.ts:40
listenerCount
▸ listenerCount<E
>(event
): number
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
Returns
number
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).listenerCount
Defined in
node_modules/typed-emitter/index.d.ts:38
listeners
▸ listeners<E
>(event
): Function
[]
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
Returns
Function
[]
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).listeners
Defined in
node_modules/typed-emitter/index.d.ts:37
off
▸ off<E
>(event
, listener
): Game
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
listener |
IGameClientEvents [E ] |
Returns
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).off
Defined in
node_modules/typed-emitter/index.d.ts:30
on
▸ on<E
>(event
, listener
): Game
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
listener |
IGameClientEvents [E ] |
Returns
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).on
Defined in
node_modules/typed-emitter/index.d.ts:25
once
▸ once<E
>(event
, listener
): Game
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
listener |
IGameClientEvents [E ] |
Returns
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).once
Defined in
node_modules/typed-emitter/index.d.ts:26
pauseKeyboardAndMouse
▸ pauseKeyboardAndMouse(): void
暂停鼠标和键盘捕获。如果有 Pointer Lock ,将释放 Pointer Lock
Returns
void
Defined in
lib/Game.ts:542
prependListener
▸ prependListener<E
>(event
, listener
): Game
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
listener |
IGameClientEvents [E ] |
Returns
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).prependListener
Defined in
node_modules/typed-emitter/index.d.ts:27
prependOnceListener
▸ prependOnceListener<E
>(event
, listener
): Game
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
listener |
IGameClientEvents [E ] |
Returns
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).prependOnceListener
Defined in
node_modules/typed-emitter/index.d.ts:28
rawListeners
▸ rawListeners<E
>(event
): Function
[]
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
Returns
Function
[]
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).rawListeners
Defined in
node_modules/typed-emitter/index.d.ts:36
removeAllListeners
▸ removeAllListeners<E
>(event?
): Game
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event? |
E |
Returns
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).removeAllListeners
Defined in
node_modules/typed-emitter/index.d.ts:31
removeListener
▸ removeListener<E
>(event
, listener
): Game
Type parameters
Name | Type |
---|---|
E |
extends keyof IGameClientEvents |
Parameters
Name | Type |
---|---|
event |
E |
listener |
IGameClientEvents [E ] |
Returns
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).removeListener
Defined in
node_modules/typed-emitter/index.d.ts:32
requestFullScreen
▸ requestFullScreen(): Promise
<void
>
Returns
Promise
<void
>
Defined in
lib/Game.ts:531
resumeKeyboardAndMouse
▸ resumeKeyboardAndMouse(): void
恢复鼠标和键盘的捕获。如果暂停前有 Pointer Lock ,在下次点击游戏界面前 Pointer Lock 将不会恢复。
Returns
void
Defined in
lib/Game.ts:549
setMaxListeners
▸ setMaxListeners(maxListeners
): Game
Parameters
Name | Type |
---|---|
maxListeners |
number |
Returns
Inherited from
(EventEmitter as new (options?: any) => TypedEmitter<IGameClientEvents>).setMaxListeners
Defined in
node_modules/typed-emitter/index.d.ts:41
setMouseMode
▸ setMouseMode(mode
): void
切换鼠标模式
Parameters
Name | Type | Description |
---|---|---|
mode |
MouseMode |
鼠标模式 |
Returns
void
Defined in
lib/Game.ts:527