java
package com.exae.seabadman;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.View;
import android.content.Intent;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.view.View.OnTouchListener;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class xiangjishi extends AppCompatActivity {
private int startl,startr,startt,startb,lastX;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xiangjishiyoshi);
qq a=new qq();
a.start();
};
int flag=1;
final Handler hans=new Handler() {
@SuppressWarnings("ResourceType")
public void handleMessage(Message msg){
super.handleMessage(msg);
LinearLayout l1=(LinearLayout)findViewById(R.id.l1);
ImageView xiogishi=(ImageView) findViewById(R.id.xiogishi);
ImageButton direction=(ImageButton) findViewById(R.id.direction);
ImageView bullet;
bullet = findViewById(R.id.bullet);
{
if(msg.what==80) {
direction.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
int ae = motionEvent.getAction();
switch (ae) {
case MotionEvent.ACTION_DOWN:
lastX = (int) motionEvent.getX();
break;
case MotionEvent.ACTION_MOVE:
int dx = (int) motionEvent.getRawX() - lastX;
int l = view.getLeft() + dx;
int b = view.getBottom();
int r = view.getRight() + dx;
int t = view.getTop();
view.layout(l, t, r, b);
lastX = (int) motionEvent.getRawX();
break;
case MotionEvent.ACTION_UP:
break;
}
Float ak = direction.getX();
xiogishi.setX(ak);
return false;
}
});
}
}
}
};
class bullet{
}
class qq extends Thread {
private Runnable qq = new Runnable() {
@Override
public void run() {
try {
hans.sendMessage(hans.obtainMessage(80));
} catch (Exception e) {
e.printStackTrace();
}
}
};
}
}
这个代码一点也不行,我想达到的效果是direction按钮按一下就可以在xiogishi图片的横坐标中发出bullet,bullet 以一定速度打出,akumo图片随机跳动,打中akumo就赢,一段时间打不到akumo我就输,最好有一些关键代码给出来,不要直接给我推飞机大战。
这个是需要提高奖金的
既然博客专家说这个是需要提高奖金的,我就路过吧。建议把发出来的代码整理好