我的问题是我不知道如何在单击我的按钮时更改可绘制画布的位置,该按钮位于主要活动中而不是surfaceview,因此工作代码应该在surfaceview上,这就是我所拥有的
public class JumpOnClick extends Activity implements OnClickListener{
DrawingSurface ds;
FrameLayout frm;
Button btnC;
int color=0xfff00000;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ds=new DrawingSurface(this);
setContentView(R.layout.activity_jump_on_click);
frm=(FrameLayout)findViewById(R.id.frameLayout);
frm.addView(ds);
btnC=(Button)findViewById(R.id.buttonColor);
btnC.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// how to connect actions in here for my sprites on my surfaceview
// for example AnimatedSprite a = new AnimatedSprite();
// if(b == null)
//b=BitmapFactory.decodeStream(res.openRawResource(R.drawable.explosion));
// a.Initialize(b, 120, 159, 7, 20, true);
// mSprites.add(a);
}
}