| | |
| | | const shuttle = new PIXI.Sprite(resources.shuttle.texture); |
| | | shuttle.width = width |
| | | shuttle.height = height |
| | | shuttle.x = item.wcsPoint.y * width;//更新坐标x |
| | | shuttle.y = item.wcsPoint.x * height;//更新坐标y |
| | | shuttle.x = item.wcsPoint.x * width;//更新坐标x |
| | | shuttle.y = item.wcsPoint.y * height;//更新坐标y |
| | | shuttle.updateMoveStatus = true;//动画执行完成 |
| | | shuttle.interactive = true; // 必须要设置才能接收事件 |
| | | shuttle.buttonMode = true; // 让光标在hover时变为手型指针 |
| | |
| | | if (shuttle.updateMoveStatus) {//动画执行完成才可继续执行动画 |
| | | shuttle.updateMoveStatus = false;//动画执行中 |
| | | // 计算两点之间的距离1 |
| | | const distance = Math.sqrt(Math.pow((item.point.x * width) - shuttle.x, 2) + Math.pow((item.point.y * height) - shuttle.y, 2)); |
| | | const distance = Math.sqrt(Math.pow((item.wcsPoint.x * width) - shuttle.x, 2) + Math.pow((item.wcsPoint.y * height) - shuttle.y, 2)); |
| | | gsap.killTweensOf(shuttle); // 杀死所有针对".class"的动画 |
| | | gsap.to(shuttle, { |
| | | x: item.point.x * width, // 目标位置 |
| | | y: item.point.y * height, // 目标位置 |
| | | x: item.wcsPoint.x * width, // 目标位置 |
| | | y: item.wcsPoint.y * height, // 目标位置 |
| | | duration: distance / 100, // 动画持续时间(秒) |
| | | ease: "power1.inOut", // 缓动类型 |
| | | onComplete: () => { |