我想執行的函數,只有當上我的舞臺演員被觸摸.. 但問題是,被執行的功能,不論在那裏它觸及了舞臺.. 即使其在執行函數舞臺上一些隨機的地方感動.. 我要當演員是touched..I具有的setBounds功能僅執行......不過其沒有工作..觸摸事件不工作properly..libgdx
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;
}
您的代碼與您所問的問題不符。如果您想在演員被觸摸時獲得回調,那麼您只需要爲該演員添加一個偵聽器。 – Jyro117 2013-03-24 23:59:23