为什么我的TextButtonlibgdx没有响应点击?
我有一个按钮,这个按钮有一个监听器,但它没有响应.该按钮正在显示,但它不会响应鼠标点击.
public MyStage extends Stage {
...
next.addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
{
Gdx.app.log(ApothecaryGame.LOG, "Pressed: Next button.");
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
Gdx.app.log( ApothecaryGame.LOG, "Released: Next button.");
super.touchUp( event, x, y, pointer, button );
nextPage();
}
} );
this.addActor(next);
}
Run Code Online (Sandbox Code Playgroud) 我看不到错误,也许有人可以在这里帮助我。
我有一个使用自旋锁的自定义锁(这是学校用的)
public class Spinlock : Locker
{
Boolean locked = false;
private SpinLock spinLock = new SpinLock();
public override void LockIt()
{
try
{
spinLock.Enter(ref locked);
}
finally
{
if(locked)
spinLock.Exit();
}
}
public override void UnlockIt()
{
}
}
public abstract class Locker
{
abstract public void LockIt();
abstract public void UnlockIt();
}
Run Code Online (Sandbox Code Playgroud)
我得到的例外如下:
System.ArgumentException 未处理
Message=在调用此方法之前,必须将 takeLock 参数设置为 false。