我只想在我的舞台上的演员被触摸时才执行一个功能。但问题是无论它在舞台上的哪个位置被触摸,该功能都会被执行。即使它在舞台上的某个随机位置被触摸,该功能也会被执行。 .我希望该功能仅在演员被触摸时执行..我有设置边界...仍然无法正常工作..
public Restart()
{
atlas = new TextureAtlas(Gdx.files.internal("pages-info.atlas"));
sprite = atlas.createSprite("restart");
this.touchable = true;
sprite.setBounds(x, y, sprite.getWidth(), sprite.getHeight());
}
public void draw(SpriteBatch batch,float parentAlpha)
{
batch.draw(sprite, x, y , width, height );
}
@Override
public Actor hit(float x, float y)
{
// TODO Auto-generated method stub
Gdx.app.log( FirstGame.LOG, " restart working " );
return null;
}