public class SuperController1 extends Actor implements InputProcessor{
Texture texFire;
Stage escena;
public boolean shooting=false;
private Rectangle recFire;
public SuperController1(Stage escena){
this.escena=escena;
texFire=new Texture("button.png");
recFire=new Rectangle(50,380,50,50);
}
@Override
public void draw(Batch batch,float alpha) {
this.setSize(100, 50);
batch.draw(texFire,this.getX()+50,this.getY()+50,50,50);
}
@Override
public void act(float delta) {
super.act(delta);
}
@Override
public boolean keyDown(int keycode) {
switch(keycode) {
case Input.Keys.SPACE:
shooting=true;
return true;
default:
return false;
}
}
@Override
public boolean keyUp(int keycode) {
switch(keycode) {
case Input.Keys.SPACE:
shooting=false;
return true;
default:
return false;
}
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
Vector3 pos=new Vector3(this.getX(),this.getY(),0);
Camera cam=escena.getCamera();
cam.unproject(pos);
if(recFire.contains(screenX, screenY)) {
izquierda=true;
return true;
}else {
return false;
}
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if(recFire.contains(screenX, screenY)) {
shooting=false;
return true;
}else{
return false;
}
}
@Override
public boolean keyTyped(char character) { return false; }
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) { return false; }
@Override
public boolean mouseMoved(int screenX, int screenY) { return false; }
@Override
public boolean scrolled(float amountX, float amountY) { return false; }
}