当前位置:   article > 正文

android studio gridlayout拼图游戏(一)让图片完整显示_android studio小游戏源代码

android studio小游戏源代码

在慕课网上看到一个拼图游戏的视频,写了一个程序代码:

public class MainActivity extends AppCompatActivity {
    private boolean gamestart=false;
    private boolean isrun=false;
    private ImageView[][] iv_game_arr=new ImageView[3][5];
    private GridLayout game;
    private ImageView nullimg;
    private GestureDetector gestureDetector;

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return gestureDetector.onTouchEvent(event);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        gestureDetector.onTouchEvent(ev);
        return super.dispatchTouchEvent(ev);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        gestureDetector=new GestureDetector(this, new GestureDetector.OnGestureListener() {
            @Override
            public boolean onDown(MotionEvent motionEvent) {
                return false;
            }

            @Override
            public void onShowPress(MotionEvent motionEvent) {

            }

            @Override
            public boolean onSingleTapUp(MotionEvent motionEvent) {
                return false;
            }

            @Override
            public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
                return false;
            }

            @Override
            public void onLongPress(MotionEvent motionEvent) {

            }

            @Override
            public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
                int type=getGesture(motionEvent.getX(),motionEvent.getY(),motionEvent1.getX(),motionEvent1.getY());
                changeGesture(type);
                return true;
            }
        });
        game=(GridLayout)findViewById(R.id.grid);
        Bitmap bigm=((BitmapDrawable)getResources().getDrawable(R.drawable.pin)).getBitmap();
        int tuW=bigm.getWidth()/5;
        for (i
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/798280
推荐阅读
相关标签
  

闽ICP备14008679号