我不知道我在这里做错了什么
//This is the Bullet Class. Here All I need is the Y position (because the Bullet is going only Y. The image which is in my drawable hdpi folder contains the image of my bullet.
public class Bulletbun extends GameObject {
private int deltaY;
private android.media.Image img;
public Bulletbun(final int xPos, final int yPos, final Image img){
this.img= img;
this.xPos=xPos;
this.yPos=yPos;
}
public Bulletbun(float f, int i, int j, String string) {
// TODO Auto-generated constructor stub
}
@Override
public void draw(Graphics g){
g.drawImage (img, xPos, yPos, null);
}
@Override
void update() {
// TODO Auto-generated method stub
}
}
}
}
//试图让它从这里开始......这是我的OnClick。我想要的是当我触摸我制作的按钮时,图像会在屏幕的Y位置拍摄。此外,如果我多次击中它会射击不止一个(5)。但也要摧毁屏幕外的那些以节省内存。
@Override
public void onClick(View v) { //+sound
// TODO Auto-generated method stub //+sound
Bulletbun Bulletbunny= new Bulletbun(bunbutt.getX()+20, 4,4, "images/air_bunny.png");
if (barrelblast != 0)
sp.play(barrelblast, 1, 1, 0, 0, 1); //+sound
Vibrator vibe = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(90);
smoke.setVisibility(View.VISIBLE);
Handler delayedAction = new Handler();
delayedAction.postDelayed(new Runnable() {
public void run() {
smoke.setVisibility(View.INVISIBLE);
//This is my GameObject Class
package com.ramy.fallingbarrels;
import com.badlogic.gdx.Graphics;
import android.media.Image;
public abstract class GameObject {
protected Image img;
protected int xPos;
protected int yPos;
abstract void draw (Graphics g);
abstract void update();
public Image getImg() {
return img;
}
public void setImg(Image img) {
this.img = img;
}
public int getxPos() {
return xPos;
}
public void setxPos(int xPos) {
this.xPos = xPos;
}
public int getYpos() {
return yPos;
}
public void setYpos(int ypos) {
this.yPos = ypos;
}
//我试图按照教程。如果我在这里做错了,请告诉我。如果有更好的方法来做我描述的,请告诉我。