麻烦:
当我移动JoyStick时,我的ImageView也会移动(OK)
但是当我停止移动JoyStick时,我的ImageView不会移动
请帮帮我,我没有任何想法。
Look at my result (click here)
我的代码:
(GameScreen.java)
package com.twikoffin.windhack;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.harrysoft.joystickview.JoystickView;
public class GameScreen extends AppCompatActivity implements JoystickView.JoystickListener{
RelativeLayout layout_joystick;
ImageView playerImage;
TextView textView1, textView2, textView3, textView4, textView5;
float x = 0;
float y = 0;
float rotation = 0;
boolean isTouched = false;
private JoystickView joystick;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gamescreen_activity);
joystick = findViewById(R.id.my_joystick);
joystick.setJoystickListener(this);
playerImage = findViewById(R.id.player1);
}
@Override
public void onJoystickMoved(float xValue, float yValue, int id) {
y = yValue;
x = xValue;
playerImage.setX(x+playerImage.getX());
playerImage.setY(y+playerImage.getY());
}
}