如何在碰撞LibGdx后渲染和成像

时间:2015-09-14 07:29:58

标签: libgdx

我想知道为什么在渲染方法中,当我删除已经发生碰撞的图像时,它不会再绘制另一个

public class Level003 extends Level 
{
    /**
     * The TextureAtlas with the interface elements
     */


    protected SpriteBatch batch;

    protected TextureAtlas interfaceAtlas = Assets.manager.get(Constants.INTERFACE_ATLAS_PATH, TextureAtlas.class);

    protected DoubleButtonOrange teal;

    protected ArrayList<DoubleButtonOrange> relation; 

    protected RigthRectangle white;

    protected WrongRectangle orange;

    protected Vector2 coordinates;

    protected PauseButton pause;

    protected TimerLevel time;

    protected NextButton next;


    public Level003(WorldController wc)
    {
        super(wc, "Relation", "Find the relation", "Yasmin Rodriguez", Constants.GRAY);
    }

    @Override
    protected void init()
    {   
        Vector2 coordinatesPause = new Vector2(323,0);
        Vector2 coordinatesNext = new Vector2(0,0);
        GameInterface gi = new GameInterface(this, 0, Constants.INTERFACE_Y);
        pause = new PauseButton(coordinatesPause, 157, 76, gi);
        next = new NextButton(coordinatesNext, 157, 76);
        batch = new SpriteBatch();
        Vector2 coordinates = new Vector2(240,400);
        white = new RigthRectangle(coordinates);
        orange = new WrongRectangle(coordinates);
        teal = new DoubleButtonOrange(coordinates,"ciao");
        relation = new ArrayList<DoubleButtonOrange>();
        time = new TimerLevel();
        for(int i=0;i<5;i++)
            relation.add(teal);

    }

    @Override
    public void render( final SpriteBatch batch)
    {   
        for(int i=0;i<relation.size;i++)
        { 
            relation.get(i).draw(bacth);
           if(relation.get(i).collision() == true)
           { relation.get(i).removeImage();
              relation.get(i+1).draw(batch);
           }
         }

        batch.begin();
        time.drawTime(batch);
        white.draw(batch);
        orange.draw(batch);
        pause.draw(batch);
        next.draw(batch);
        batch.end();

    }

0 个答案:

没有答案