Javascript CreateJS对象可见性
我希望有人能帮忙 我在CreateJS中有一个游戏运行良好,为暂停按钮添加了功能,也运行良好,除了暂停按钮不可见,但我的所有其他对象都是:(如果我单击我知道暂停按钮的位置,则功能正常,但我就是看不到按钮 下面的代码:一旦点击我的角色,它就会进入函数pauseGame(这正在工作,暂停游戏)。这应该会使pause.visible=true。我想可能是这样,因为如果我点击暂停(我知道它存在的坐标),游戏会重新启动(进入函数startGame),问题是当我单击暂停游戏时,它会暂停,但我看不到我的按钮,上面写着“游戏暂停,单击此处继续游戏”,但如果我单击它,游戏会重新启动。这是与zindex放置有关,还是其他原因导致对象不可见Javascript CreateJS对象可见性,javascript,html5-canvas,createjs,Javascript,Html5 Canvas,Createjs,我希望有人能帮忙 我在CreateJS中有一个游戏运行良好,为暂停按钮添加了功能,也运行良好,除了暂停按钮不可见,但我的所有其他对象都是:(如果我单击我知道暂停按钮的位置,则功能正常,但我就是看不到按钮 下面的代码:一旦点击我的角色,它就会进入函数pauseGame(这正在工作,暂停游戏)。这应该会使pause.visible=true。我想可能是这样,因为如果我点击暂停(我知道它存在的坐标),游戏会重新启动(进入函数startGame),问题是当我单击暂停游戏时,它会暂停,但我看不到我的按钮,
function pauseGame(event)
{
if(exportRoot.gameOver.visible == false)
{
exportRoot.pause.visible = true;
console.log("Pausing");
inPlay = false;
}
}
function startGame(event)
{
if (exportRoot.gameOver.visible == false)
{
inPlay = true;
exportRoot.pause.visible = false;
}
}
您应该检查的几件事:
- Opacity, just try: console.log(exportRoot.pause.alpha); if it's not 1, something might be wrong.
- Visibility: console.log(exportRoot.pause.visible), if false, something is wrong.
- last thing: try addChild(exportRoot.pause) to see if the button is under some other element.