我试图在用户触摸屏幕时显示项目符号
我在这里做子弹
public Projectile(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
paint = new Paint();
bulletBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.bullet);
}
public interface ProjectileListener {
public void onProjectileChanged(float delta, float angle);
}
public void setProjectileListener(ProjectileListener l) {
listener = l;
}
public void setProjectileDirection(int x, int y, int size){
pos = new Rect(x, y, size, size);
invalidate();
}
protected void onDraw(Canvas c) {
c.drawBitmap(bulletBitmap, pos, pos, paint);
super.onDraw(c);
}
并在这里调用它
Projectile p = new Projectile(TowerAnimation.this);
p.setProjectileDirection(x, y, 50);
projectiles.add(p);
Canvas c = null;
p.onDraw(c);
但是我在这条线上遇到了错误
c.drawBitmap(bulletBitmap, pos, pos, paint);
我对drawBitmap有什么问题吗?谢谢