悬浮球回调sin与cos给Activity

混江龙づ霸主 提交于 2019-11-28 15:59:17

if (getDistance(x, mStartX, y, mStartY) < moveRange) {
updateViewPosition();
} else {
//斜率
float k = (y - mStartY) / (x - mStartX);
double rx;
double ry;
rx = Math.sqrt(moveRange * moveRange / (k * k + 1));
if ((x - mStartX) < 0) {
rx = -rx;
}
ry = k * rx;
wmParams.x = (int) (rx + 700);
wmParams.y = (int) (ry + 1900);
//回调sin,cos
listener.onSpeakListener(ry / radius, rx / radius);
wm.updateViewLayout(this, wmParams); //刷新显示
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Activity接收参数

customeMovebutton.setOnSpeakListener(new CustomeMovebutton.OnSpeakListener() {
@Override
public void onSpeakListener(double sin, double cos) {
speedLat = -speed * sin;
speedLon = speed * cos;
}
});
————————————————

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!