ttGame.d.ts 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /**
  2. * 广告
  3. */
  4. declare namespace ttGame {
  5. class BaseADManager {
  6. protected STATE_LOADED: number;
  7. protected STATE_SHOW: number;
  8. protected STATE_EXPOSURE: number;
  9. protected _ids: {
  10. bannerAdID: string;
  11. rewardedAdID: string;
  12. interstitialAdID: string;
  13. };
  14. protected _adState: {
  15. bannerAdState: number;
  16. rewardedAdState: number;
  17. interstitialAdState: number;
  18. };
  19. protected _bannerAd: any;
  20. protected _rewardedVideoAd: any;
  21. protected _interstitialAd: any;
  22. protected _bannerAdWidth: number;
  23. constructor(bannerAdID: string, rewardedAdID: string, interstitialAdID: string);
  24. /** 创建Banner广告 */
  25. private createBannerAd;
  26. protected onBannerResize(size: any): void;
  27. /** banner报错 */
  28. protected onBannerError(err: any): void;
  29. /** banner加载完成 */
  30. protected onBannerLoaded(): void;
  31. /** 添加状态(加载完或显示),并查看是否曝光(加载完且显示) */
  32. protected addBannerState(state: number): void;
  33. /** 显示 banner 广告 */
  34. showBanner(): void;
  35. /** 隐藏 banner 广告 */
  36. hideBanner(): void;
  37. /** 创建激励视频广告 */
  38. private createRewardedVideoAd;
  39. /** 激励视频广告报错 */
  40. protected onRewardedVideoAdError(err: any): void;
  41. /** 激励视频广告关闭 */
  42. protected onRewardedVideoAdClosed(res: any): void;
  43. /** 激励视频广告加载完成 */
  44. protected onRewardedVideoAdLoaded(res: any): void;
  45. /** 添加状态(加载完或显示),并查看是否曝光(加载完且显示) */
  46. protected addRewardedState(state: number): void;
  47. /**
  48. * 显示激励广告
  49. */
  50. showRewardedVideoAd(): void;
  51. /** 创建插屏广告 */
  52. private createInterstitialAd;
  53. /** 插屏广告报错 */
  54. protected onInterstitialAdError(err: any): void;
  55. /** 插屏广告关闭 */
  56. protected onInterstitialAdClosed(res: any): void;
  57. /** 插屏广告加载完成 */
  58. protected onInterstitialAdLoaded(res: any): void;
  59. /** 添加状态(加载完或显示),并查看是否曝光(加载完且显示) */
  60. protected addInterstitialState(state: number): void;
  61. /**
  62. * 显示插屏广告
  63. */
  64. showInterstitialAd(): void;
  65. }
  66. }
  67. declare namespace ttGame {
  68. class ADManager extends BaseADManager {
  69. constructor();
  70. protected onBannerResize(size: any): void;
  71. }
  72. }
  73. declare var tt: any;
  74. declare namespace ttGame {
  75. class BasePlatform extends core.BasePlatform {
  76. ad: ADManager;
  77. /** 平台类型 */
  78. openDataContext: any;
  79. private recorder;
  80. systemInfo: SystemInfo;
  81. appID: string;
  82. accessToken: string;
  83. constructor();
  84. /** 初始化监听事件 */
  85. private initEvent;
  86. /**
  87. * 回到前台的事件处理函数
  88. */
  89. private onShow;
  90. /**
  91. * 小游戏隐藏到后台事件处理函数。
  92. */
  93. private onHide;
  94. /**
  95. * 初始化(登陆、获取用户信息、设置默认分享)
  96. */
  97. init(): void;
  98. /**
  99. * 登陆 - 获取Code
  100. */
  101. private login;
  102. /**
  103. * 登陆完成回调
  104. */
  105. private loginComplete;
  106. /** 获取AccessToken接口 */
  107. private getAccessToken;
  108. private httpUserInfoCallback;
  109. private setUserInfo;
  110. private httpModifyUserInfoCallback;
  111. /**
  112. * 查看是否已授权
  113. */
  114. private checkSetting;
  115. authorizeUserInfo(): void;
  116. authorizeScreenRecord(): void;
  117. /**
  118. * 获取用户信息
  119. */
  120. private getUserInfo;
  121. /** 透传资源到子域 */
  122. protected sendRes(): void;
  123. /** 获取启动场景(php用到) */
  124. private get startScene();
  125. private _sharing;
  126. /**
  127. * 设置默认分享(微信小游戏小程序不再支持分享回调https://developers.weixin.qq.com/community/develop/doc/0000447a5b431807af57249a551408)
  128. */
  129. private setDefaultShare;
  130. /** 关注 */
  131. attention(): void;
  132. /** 收藏 */
  133. addToFavorite(): void;
  134. /** 获取视频列表页面(字节用) */
  135. getVideoList(): void;
  136. /** 跳转到分享的视频播放页面 */
  137. navigateToVideoView(videoId: string): void;
  138. /**
  139. * 主动分享
  140. */
  141. share(title?: string): void;
  142. /** 分享的数据(需要重写) */
  143. protected getShareData(title?: string): any;
  144. /** 视频分享 */
  145. shareVideo(videoPath: string): void;
  146. /** 视频分享的数据(需要重写) */
  147. protected getVideoShareData(videoPath: string): any;
  148. private shareSuccess;
  149. private shareFail;
  150. private shareComplete;
  151. /** 获取本地缓存数据 */
  152. getStorageSync(key: string): any;
  153. /** 保存数据本地缓存 */
  154. setStorageSync(key: string, data: any): any;
  155. /**
  156. * 向开放数据域发送消息
  157. * @param message {} 要发送的消息,message 中及嵌套对象中 key 的 value 只能是 primitive value。即 number、string、boolean、null、undefined。
  158. */
  159. postMessage(message: {}): void;
  160. /** 传递UserInfo */
  161. private sendUserInfo;
  162. /** clearCanvas */
  163. clearCanvas(): void;
  164. /** 显示排行榜 */
  165. showRank(rankType: number): void;
  166. /** 关闭排行榜 */
  167. hideRank(): void;
  168. /** 排行榜切页(-1上一页 0下一页 >0跳转到具体页数) */
  169. rankChangePage(page: number): void;
  170. /** 保存最高分 */
  171. saveScore(score: number): void;
  172. /** 显示或隐藏Banner广告 */
  173. adBanner(isShow: boolean): void;
  174. /** 显示激励式广告 */
  175. adRewardedVideo(): void;
  176. /** 显示插屏广告 */
  177. adInterstitial(): void;
  178. /** 显示或隐藏格子广告 */
  179. adGrid(isShow: boolean): void;
  180. private initRecorder;
  181. /** 开始录屏 */
  182. startRecord(): void;
  183. /** 停止录屏 */
  184. stopRecord(): void;
  185. private _moreGameBtn;
  186. /**
  187. * 更多游戏图标
  188. * @parame isShow 是否显示
  189. */
  190. moreGameBtn(isShow: boolean): MoreGameIcon;
  191. /** 更多游戏按钮参数 */
  192. protected get moreGameParams(): {
  193. x: number;
  194. y: number;
  195. w: number;
  196. h: number;
  197. appLaunchOptions: any[];
  198. };
  199. /** 显示更多游戏 */
  200. showMoreGame(): void;
  201. }
  202. }
  203. declare namespace ttGame {
  204. class Platform extends BasePlatform implements core.IPlatform {
  205. constructor();
  206. /** 普通分享的数据 */
  207. protected getShareData(title?: string): any;
  208. /** 视频分享的数据 */
  209. protected getVideoShareData(videoPath: string): any;
  210. /** 透传资源到子域 */
  211. protected sendRes(): void;
  212. /** 更多游戏按钮参数 */
  213. protected get moreGameParams(): {
  214. x: number;
  215. y: number;
  216. w: number;
  217. h: number;
  218. appLaunchOptions: any[];
  219. };
  220. /** 显示即将超越好友 */
  221. showSurpass(score: number): void;
  222. /**显示称号 */
  223. showTitle(score: number): void;
  224. /** 发送登录检查保存分数 */
  225. sendLoginCheck(): void;
  226. }
  227. }
  228. declare var tt: any;
  229. declare namespace ttGame {
  230. class SendRes {
  231. static sendAtlasList(urls: string[]): void;
  232. static sendSinglePicList(urls: string[]): void;
  233. static sendJsonList(urls: string[]): void;
  234. }
  235. }
  236. declare namespace ttGame {
  237. class SystemInfo {
  238. info: {
  239. SDKUpdateVersion: string;
  240. SDKVersion: string;
  241. appName: string;
  242. batteryLevel: number;
  243. benchmarkLevel: number;
  244. brand: string;
  245. devicePixelRatio: number;
  246. errMsg: string;
  247. fontSizeSetting: number;
  248. language: string;
  249. model: string;
  250. nativeSDKVersion: string;
  251. pixelRatio: number;
  252. platform: string;
  253. safeArea: {
  254. top: number;
  255. bottom: number;
  256. left: number;
  257. right: number;
  258. width: number;
  259. height: number;
  260. };
  261. screenHeight: number;
  262. screenWidth: number;
  263. statusBarHeight: number;
  264. system: string;
  265. version: string;
  266. wifiSignal: number;
  267. windowHeight: number;
  268. windowWidth: number;
  269. };
  270. constructor();
  271. /** 设备:android,ios */
  272. get device(): string;
  273. /** app名字 */
  274. get appName(): string;
  275. }
  276. }
  277. declare namespace ttGame {
  278. class MoreGameIcon extends Laya.Box {
  279. private ICON_SIZE;
  280. private _icon;
  281. private _label;
  282. private _tweentimeLite;
  283. private _appLaunchOptions;
  284. private _iconUrls;
  285. private _index;
  286. constructor(params: {
  287. x: number;
  288. y: number;
  289. w: number;
  290. h: number;
  291. appLaunchOptions: any[];
  292. });
  293. onAwake(): void;
  294. private getRes;
  295. onEnable(): void;
  296. private changeSkin;
  297. private iconLoaded;
  298. private onClick;
  299. onDisable(): void;
  300. destroy(): void;
  301. }
  302. }
  303. //# sourceMappingURL=ttGame.d.ts.map