zoukankan      html  css  js  c++  java
  • Android 扒开美女衣服

    本文主要实现一个小的扒开美女衣服的游戏项目

    效果如下:

    项目布局设计:

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity" >
    
        <ImageView
            android:id="@+id/iv_after"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    
        <ImageView
            android:id="@+id/iv_pre"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    
    </FrameLayout>

    逻辑部分代码:

    public class MainActivity extends Activity {
    
        private ImageView iv_after;
        private ImageView iv_before;
    
        private Bitmap alterBitmap;
        private Canvas canvas;
    
        private Paint paint;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            BitmapFactory.Options opts = new Options();
            opts.inSampleSize = 2;
            iv_after = (ImageView) findViewById(R.id.iv_after);
            iv_before = (ImageView) findViewById(R.id.iv_pre);
    
            Bitmap after = BitmapFactory.decodeResource(getResources(),
                    R.drawable.after19, opts);
            Bitmap before = BitmapFactory.decodeResource(getResources(),
                    R.drawable.pre19, opts);
    
            // 可以修改的空白的bitmap
            alterBitmap = Bitmap.createBitmap(before.getWidth(),
                    before.getHeight(), before.getConfig());
    
            canvas = new Canvas(alterBitmap);
            paint = new Paint();
            paint.setStrokeWidth(5);
            paint.setColor(Color.BLACK);
            canvas.drawBitmap(before, new Matrix(), paint);
    
            iv_after.setImageBitmap(after);
            iv_before.setImageBitmap(alterBitmap);
    
            iv_before.setOnTouchListener(new OnTouchListener() {
    
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
    
                        break;
                    case MotionEvent.ACTION_MOVE:
                        int newX = (int) event.getX();
                        int newY = (int) event.getY();
                        for (int i = -6; i < 6; i++) {
                            for (int j = -6; j < 6; j++) {
                                alterBitmap.setPixel(i + newX, j + newY,
                                        Color.TRANSPARENT);
    
                            }
                        }
                        iv_before.setImageBitmap(alterBitmap);
    
                        break;
                    case MotionEvent.ACTION_UP:
    
                        break;
    
                    default:
                        break;
                    }
    
                    return true;
                }
            });
    
        }
    
    }
  • 相关阅读:
    ionic入门之AngularJS扩展基本布局
    ionic入门之AngularJS扩展(一)
    test
    面试题小整理
    使用Code first 进行更新数据库结构(数据迁移)
    SQL模糊查询与删除多条语句复习
    GridView 根据要求显示指定值
    个人工作记录---工作中遇到的sql查询语句解析
    数据库,inner join,left join right join 的区别
    利用set实现去重
  • 原文地址:https://www.cnblogs.com/wuyudong/p/5844938.html
Copyright © 2011-2022 走看看