This is my rocket where I am looking for an intersecting Supply to increase its own bullets or fuel from the respective Supply type.
This is my Supply constructor, it has 2 types.
I am basically having trouble writing the intersection part of the code in the method checkPowerUp(). How do I check the Supply's type from the way I've written the code? The way I've written the code doesn't compile properly.
private void checkPowerUp() { Actor powerUp = getOneIntersectingObject(Supply.class); if(powerUp!=null){ if(powerUp.getType()==1){ bullets=bullets+50; } if(powerUp.getType()==0){ fuel=fuel+100; } getWorld().removeObject(powerUp); } }
public int type; public Supply(int type) { addForce(singlePush); life = 350; switch(type){ case 0: setImage("gas.png");break; case 1: setImage("bullets.png");break; } this.type=type; }