加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
在CSS里清理掉body的光标 body { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; cursor: none; overflow: hidden;
在CSS里清理掉body的光标
body {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: none;
overflow: hidden;
在index中加入div标记 <div id="cursor"></div>
在index中加入div标记
<div id="cursor"></div>
添加DOM的样式 #cursor{ background-image: url(../img/ui/鼠标.png); position:absolute; z-index:200; top:50%; left:50%; width:32px; height:32px; background-size: 100%; animation: size 1s infinite; } @keyframes size { 0% { transform:scale(1); } 50% { transform:scale(0.9); } 100% { transform:scale(1); } }
添加DOM的样式
#cursor{
background-image: url(../img/ui/鼠标.png);
position:absolute;
z-index:200;
top:50%;
left:50%;
width:32px;
height:32px;
background-size: 100%;
animation: size 1s infinite;
}
@keyframes size {
0% {
transform:scale(1);
}
50% {
transform:scale(0.9);
}
100% {
transform:scale(1);
}
}
添加监听 LIM.cursor=document.getElementById("cursor") /////光标 TouchInput._onMouseMove = function(event) { const x = Graphics.pageToCanvasX(event.pageX); const y = Graphics.pageToCanvasY(event.pageY); LIM.cursor.style.left =event.pageX + "px" LIM.cursor.style.top = event.pageY + "px" if (this._mousePressed) { this._onMove(x, y); } else if (Graphics.isInsideCanvas(x, y)) { this._onHover(x, y); } };
添加监听
LIM.cursor=document.getElementById("cursor")
/////光标
TouchInput._onMouseMove = function(event) {
const x = Graphics.pageToCanvasX(event.pageX);
const y = Graphics.pageToCanvasY(event.pageY);
LIM.cursor.style.left =event.pageX + "px"
LIM.cursor.style.top = event.pageY + "px"
if (this._mousePressed) {
this._onMove(x, y);
} else if (Graphics.isInsideCanvas(x, y)) {
this._onHover(x, y);
}
};
尝试过在Scene_Base创建时加一个鼠标精灵,这样就能让鼠标和游戏缩放同步,但是总有各种BUG。
有大佬有现成的方案吗 |