我想制作一个页面,您可以在其中拖动图像(并播放一些动画)
所以我正在做某事(我认为这并不理想 - 所以我需要你的帮助):
我的代码:
ButtonIMG = BitmapFactory.decodeResource(getResources(), R.drawable.ButtonIMG );
Canvas c = null;
while (true) {
if (!holder.getSurface().isValid()) {
continue;
}
if (gifCounter<10){
animataion = BitmapFactory.decodeResource(getResources(), R.drawable.animataion1);
gifCounter++;
}
if (gifCounter<20 && gifCounter>=10){
animataion = BitmapFactory.decodeResource(getResources(), R.drawable.animataion2);
gifCounter++;
}
if (gifCounter<30 && gifCounter>=20){
animataion = BitmapFactory.decodeResource(getResources(), R.drawable.animataion3);
gifCounter++;
}
if (gifCounter>=30){
gifCounter=0;
}
c = holder.lockCanvas();
c.drawARGB(255, 220, 220, 220);
c.drawBitmap(ButtonIMG, x, y, null);
c.drawBitmap(animataion, 100, 100, null);
}
. . .
public boolean onTouch(View v, MotionEvent me){
switch (me.getAction()) {
case MotionEvent.ACTION_DOWN:
x = me.getX();
y = me.getY();
break;
}
}