android (拼图游戏)数字推盘的简单实现

看了徐宜生android群英传的拼图例子,也想参照他的写一个拼图游戏。本文的拼图游戏中对图片处理的方式和书中的基本是一直的,但是游戏方法却与之不同。
书中的拼图是通过GridView的点击事件,交换两张图片,达成拼图目的,但是个人认为这样的拼图过于简单,很容易就能达成目标,
于是收到小时候玩的数字推盘的游戏的启发,将数字替换成文字,大大增加了游戏的难度(ps:本人目前没玩出来过)。主要使用recyclerView与ontouch结合,实现拼图效果,当然判断拼图是否有解的算法还没给出,敬请期待后续更新。
首先简单介绍一下布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tool="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tool:context=".activity.GameActivity">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:popupTheme="@style/Theme.AppCompat.Light.NoActionBar">

    </android.support.v7.widget.Toolbar>

    <LinearLayout
        android:id="@+id/lay_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="@dimen/margin_8dp"
                android:ellipsize="end"
                android:gravity="center"
                android:maxLines="1"
                android:text="@string/jigsaw_time"
                android:textSize="@dimen/sp_middle" />

            <TextView
                android:id="@+id/jigsaw_time"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="@dimen/margin_8dp"
                android:ellipsize="end"
                android:gravity="center"
                android:maxLines="1"
                android:textSize="@dimen/sp_middle" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="@dimen/margin_8dp"
                android:ellipsize="end"
                android:gravity="center"
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值