它的樣子,你想增加圖像的尺寸在高度明智的,當用戶觸摸屏幕,並增加直到他刪除屏幕他的手指,然後通過90度旋轉的形象。
我想這一點,希望它可能給你一些參考
public class TestGame extends Game implements InputProcessor{
Texture pixelTex;
SpriteBatch spriteBatch;
Sprite sprite;
float w,h;
TouchStatus touchStatus=TouchStatus.NONE;
enum TouchStatus {
TOUCH_DOWN,TOUCH_UP,NONE
}
@Override
public void create() {
w=Gdx.graphics.getWidth();
h=Gdx.graphics.getHeight();
Gdx.input.setInputProcessor(this);
spriteBatch=new SpriteBatch();
pixelTex= getPixmapTexture(Color.WHITE);
sprite=new Sprite(pixelTex);
sprite.setColor(Color.YELLOW);
sprite.setSize(10,10);
sprite.setPosition(200,200);
}
@Override
public void render() {
super.render();
Gdx.gl.glClearColor(1,1,1,1);
gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
spriteBatch.begin();
sprite.draw(spriteBatch);
spriteBatch.end();
if(touchStatus==TouchStatus.TOUCH_DOWN){
if(sprite.getY()+sprite.getHeight()<h){
float currentHeight=sprite.getHeight();
currentHeight++;
sprite.setSize(sprite.getWidth(),currentHeight);
}
}
if(touchStatus==TouchStatus.TOUCH_UP){
float currentRotation=sprite.getRotation();
currentRotation--;
sprite.setRotation(currentRotation);
if(currentRotation<=-90)
touchStatus=TouchStatus.NONE;
}
}
@Override
public void resize(int width, int height) {
super.resize(width, height);
}
@Override
public void dispose() {
super.dispose();
pixelTex.dispose();
spriteBatch.dispose();
}
@Override
public boolean keyDown(int keycode) {
return false;
}
@Override
public boolean keyUp(int keycode) {
return false;
}
@Override
public boolean keyTyped(char character) {
return false;
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if(touchStatus==TouchStatus.NONE)
touchStatus=TouchStatus.TOUCH_DOWN;
return false;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if(touchStatus==TouchStatus.TOUCH_DOWN)
touchStatus=TouchStatus.TOUCH_UP;
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(int amount) {
return false;
}
public static Texture getPixmapTexture(Color color){
return new Texture(getPixmapRectangle(1, 1, color));
}
public static Pixmap getPixmapRectangle(int width, int height, Color color){
Pixmap pixmap=new Pixmap(width, height, Pixmap.Format.RGBA8888);
pixmap.setColor(color);
pixmap.fillRectangle(0,0, pixmap.getWidth(), pixmap.getHeight());
return pixmap;
}
}
顯示您MyInputProcessor。另外,什麼'angleValue'爲?你是否意識到你在每一幀上增加了一個? – Tenfour04