Skip to content

Commit 2a0f6f0

Browse files
author
ranpeng
committed
v1.1.3
v1.1.3
1 parent 5cecc7b commit 2a0f6f0

File tree

12 files changed

+212
-7
lines changed

12 files changed

+212
-7
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@
66

77
直接 import dist/tcg-sdk,导出的为umd 格式
88

9+
## Samples
10+
11+
可参考samples 文件夹下,Mobile/PC demo
12+
13+
## Plugin
14+
15+
新增遥感插件
16+
917
## 说明文档
1018

11-
[使用例子](demo/demo.html)
19+
[使用例子](samples/)
20+
21+
[快速入门](https://cloud.tencent.com/document/product/1162/46135)
22+
23+
[接口申明文件](dist/tcg-sdk//index.d.ts)
1224

13-
[快速入门](https://cloud.tencent.com/document/product/1162/46135)

changelog.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
### [1.1.3](https://github.com/tencentyun/cloudgame-js-sdk/releases/tag/v1.1.3)@2022.03.23
2+
3+
**新增**
4+
5+
- PC 端操作手游
6+
- 移动端虚拟摇杆插件
7+
8+
**变更**
9+
10+
- 取消打印数据通道消息发送日志
11+
12+
**修复**
13+
14+
- Safari 下多次重连会导致连接不成功问题
15+
116
### [1.1.2](https://github.com/tencentyun/cloudgame-js-sdk/releases/tag/v1.1.2)@2022.02.21
217

318
**新增**

dist/tcg-sdk/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export interface ServerSideDescription {
103103
readonly sdp?: string;
104104
readonly server_ip?: string;
105105
readonly server_version?: string;
106+
readonly server_port?: string;
106107
readonly region?: string;
107108
readonly instance_type?: string; // L1 S1 M1
108109
readonly message?: string;

dist/tcg-sdk/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
### [1.0.0](https://github.com/tencentyun/cloudgame-js-sdk/releases/tag/v1.1.3)@2022.02.21
2+
3+
**新增**
4+
5+
- 虚拟摇杆插件
6+

plugin/joystick/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 云游戏插件项目 - 摇杆
2+
3+
接口描述见申明文件(joystick.d.ts)
4+
5+
## 使用方法
6+
7+
> 需结合TCGSDK 一起使用,使用前请确保TCGSDK 已被正常加载
8+
9+
1. import joystick plugin
10+
11+
```javascript
12+
import { joystick } from 'tcg-plugin/joystick/joystick';
13+
```
14+
15+
2. create joystick, 具体参数可以参见申明文件 create 方法
16+
17+
```javascript
18+
const j = joystick.create({
19+
zone: document.querySelector('#your-element')
20+
});
21+
```
22+
23+
3. 监听对应事件(如果sendData 为true(默认值 true),插件会自动发送对应指令)
24+
25+
```javascript
26+
j.on('move', (data) => {
27+
const { degree } = data.angle;
28+
console.log('degree', degree);
29+
});
30+
```
31+
32+
33+
如有疑问和需求,可随时联系 ranpeng

plugin/joystick/joystick.d.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
export interface CreateConfig {
2+
/**
3+
* 摇杆挂载节点,默认 document.body
4+
*/
5+
zone?: HTMLElement;
6+
/**
7+
* 摇杆尺寸,默认 `100px`
8+
*/
9+
size?: number;
10+
/**
11+
* 相对于挂载节点的位置
12+
* 默认值 `{top: 50, left: 50}`,及根据size 剧中
13+
*/
14+
position?: {
15+
top?: number;
16+
right?: number;
17+
bottom?: number;
18+
left?: number;
19+
};
20+
/**
21+
* 锁定X 轴移动, 默认值 `false`
22+
*/
23+
lockX?: boolean;
24+
/**
25+
* 锁定Y 轴移动, 默认值 `false`
26+
*/
27+
lockY?: boolean;
28+
/**
29+
* 两种摇杆样式 wasd/上下左右, 默认值 `dpad_updown`
30+
*/
31+
type?: 'dpad_wasd' | 'dpad_updown';
32+
/**
33+
* 是否自动发送移动数据, 默认值 `true`
34+
*/
35+
sendData?: boolean;
36+
/**
37+
* 摇杆背景图, http/https 地址
38+
* 不填采用默认图片
39+
* @back 底图
40+
* @front 按钮图
41+
* @frontPressed 按钮被按下后的图片
42+
*/
43+
joystickImage?: {
44+
back?: string;
45+
front?: string;
46+
frontPressed?: string;
47+
};
48+
/**
49+
* end 后复位摇杆,默认值 `true`
50+
*/
51+
restJoystick?: boolean;
52+
/**
53+
* 操作阀值,暂未启用
54+
*/
55+
threshold?: number;
56+
/**
57+
* fade 动画时间,暂未启用
58+
*/
59+
fadeTime?: number;
60+
/**
61+
* 根据android 编辑倒出的json 数据显示摇杆,暂未启用
62+
*/
63+
configJson?: any; // 有android 端倒出的json 文件
64+
}
65+
66+
export type JoystickEventTypes = 'start' | 'move' | 'end' | 'added';
67+
68+
/**
69+
* 摇杆move 时候返回的数据
70+
*/
71+
export interface JoystickOutputData {
72+
angle: {
73+
degree: number;
74+
radian: number;
75+
};
76+
distance: number;
77+
force: number;
78+
identifier: number;
79+
lockX: boolean;
80+
lockY: boolean;
81+
position: {
82+
x: number;
83+
y: number;
84+
};
85+
pressure: number;
86+
raw: {
87+
distance: number;
88+
position: {
89+
x: number;
90+
y: number;
91+
};
92+
};
93+
vector: {
94+
x: number;
95+
y: number;
96+
};
97+
direction?: {
98+
angle: string;
99+
x: string;
100+
y: string;
101+
};
102+
}
103+
104+
export interface Joystick {
105+
/**
106+
* @param type 对应的事件
107+
* @param handler 回调函数
108+
*/
109+
on<T extends JoystickEventTypes>(
110+
type: T,
111+
handler: (data: T extends 'move' ? JoystickOutputData : null) => void,
112+
): void;
113+
destroy(): void;
114+
}
115+
116+
declare class JoystickStatic {
117+
create(params: CreateConfig): Joystick;
118+
}
119+
120+
export declare const joystick: JoystickStatic;

plugin/joystick/joystick.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/mobile/index.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,26 @@
2424
width: 100%;
2525
height: 100%;
2626
}
27+
28+
#plugin-point {
29+
position: absolute;
30+
left: 100px;
31+
bottom: 50px;
32+
width: 100px;
33+
height: 100px;
34+
}
35+
2736
</style>
2837
</head>
2938

3039
<body>
3140
<div id="demo-container">
3241
<div id="mount-point"></div>
42+
<div id="plugin-point"></div>
3343
</div>
3444
<script type="text/javascript" src="../../dist/tcg-sdk/index.js"></script>
35-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"></script>
45+
<script type="text/javascript" src="../../plugin/joystick/joystick.js"></script>
46+
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/axios/0.26.1/axios.min.js"></script>
3647
<script>
3748

3849
const startGame = async () => {
@@ -68,6 +79,11 @@
6879
// 连接成功回调
6980
onConnectSuccess: async (res) => {
7081
console.log('onConnectSuccess', res);
82+
83+
// // 添加遥感
84+
// const j = joystick.create({
85+
// zone: document.querySelector('#plugin-point'),
86+
// });
7187
},
7288
// 网络中断/被踢触发此回调
7389
onDisconnect: (res) => {

samples/mobile/queue/bg.png

100755100644
File mode changed.

0 commit comments

Comments
 (0)