Adobe Animate CC WebGL 翻转状态
Adobe Animate CC WebGL rollover state
我正在创建一个 WebGL canvas 并且我正在尝试使用 onmousemove 片段为动画剪辑按钮创建鼠标悬停。
首先我将按钮的滚动状态设置为不可见,如下所示:
this.YesHOT.setVisible(false);
然后我使用 onmousemove 函数使其在按钮上方时可见:
canvas.onmousemove = function(e) {
var boundingRect = this.Yes.getBounds(this);
if(isMouseOverSymbol(e.offsetX, e.offsetY, boundingRect)) {
this.YesHOT.setVisible(true);
}
}.bind(this);
//Function to check whether the specified point lies within the rect.
function isMouseOverSymbol(pointX, pointY, rect) {
if(rect.left <= pointX && pointX <= rect.left + rect.width)
if(rect.top <= pointY && pointY <= rect.top + rect.height)
return true;
return false;
}
这行得通,但是翻滚状态仍然可见并且不会关闭。我如何让它关闭?
您从未真正拨打过 this.YesHOT.setVisible(false)
电话。如果我理解你的意图,代码应该是这样的:
canvas.onmousemove = function(e) {
var boundingRect = this.Yes.getBounds(this);
// if mouse cursor is over the "hot" area, show effect. Otherwise hide.
this.YesHOT.setVisible(isMouseOverSymbol(e.offsetX, e.offsetY, boundingRect));
}.bind(this);
// also hide the effect when mouse completely leaves the canvas
canvas.onmouseleave = function () {
this.YesHOT.setVisible(false);
}.bind(this);
我正在创建一个 WebGL canvas 并且我正在尝试使用 onmousemove 片段为动画剪辑按钮创建鼠标悬停。
首先我将按钮的滚动状态设置为不可见,如下所示:
this.YesHOT.setVisible(false);
然后我使用 onmousemove 函数使其在按钮上方时可见:
canvas.onmousemove = function(e) {
var boundingRect = this.Yes.getBounds(this);
if(isMouseOverSymbol(e.offsetX, e.offsetY, boundingRect)) {
this.YesHOT.setVisible(true);
}
}.bind(this);
//Function to check whether the specified point lies within the rect.
function isMouseOverSymbol(pointX, pointY, rect) {
if(rect.left <= pointX && pointX <= rect.left + rect.width)
if(rect.top <= pointY && pointY <= rect.top + rect.height)
return true;
return false;
}
这行得通,但是翻滚状态仍然可见并且不会关闭。我如何让它关闭?
您从未真正拨打过 this.YesHOT.setVisible(false)
电话。如果我理解你的意图,代码应该是这样的:
canvas.onmousemove = function(e) {
var boundingRect = this.Yes.getBounds(this);
// if mouse cursor is over the "hot" area, show effect. Otherwise hide.
this.YesHOT.setVisible(isMouseOverSymbol(e.offsetX, e.offsetY, boundingRect));
}.bind(this);
// also hide the effect when mouse completely leaves the canvas
canvas.onmouseleave = function () {
this.YesHOT.setVisible(false);
}.bind(this);