Android 游戏闯关

GameStageView是一款用于创建游戏闯关界面的Android自定义View,支持设置关卡数量、已通关数、头像资源等属性,并提供点击事件监听。通过XML布局和自定义属性轻松实现2字形路径的关卡展示,同时支持过度绘制的优化处理。
摘要由CSDN通过智能技术生成

GameStageView

游戏闯关View、闯关文字、解锁 + 未解锁、2字形路径

预览

在这里插入图片描述

资源

名字资源
AARgame_stage_view.aar
GitHubGameStageView
GiteeGameStageView

Maven

1.build.grade | setting.grade

repositories {
	...
	maven { url 'https://jitpack.io' }
}

2./app/build.grade

dependencies {
	implementation 'com.github.RelinRan:GameStageView:2022.7.29.1'
}

xml

注意:Item个数过多情况请嵌套NestedScrollView或者ScrollView

<androidx.widget.GameStageView
    android:id="@+id/game_stage"
    android:layout_width="match_parent"
    app:itemHeadSrc="@mipmap/ic_head"
    android:layout_height="wrap_content" />

attrs.xml

<!--item宽度-->
<attr name="itemWidth" format="dimension" />
<!--item高度-->
<attr name="itemHeight" format="dimension" />
<!--item圆角大小-->
<attr name="itemRadius" format="dimension" />
<!--item文字大小-->
<attr name="itemTextSize" format="dimension" />
<!--分割线颜色-->
<attr name="itemDividerColor" format="color" />
<!--水平分割线宽度-->
<attr name="itemDividerHorizontalWidth" format="dimension" />
<!--水平分割线高度-->
<attr name="itemDividerHorizontalHeight" format="dimension" />
<!--垂直分割线宽度-->
<attr name="itemDividerVerticalWidth" format="dimension" />
<!--垂直分割线高度-->
<attr name="itemDividerVerticalHeight" format="dimension" />
<!--item总数-->
<attr name="itemCount" format="integer" />
<!--列数-->
<attr name="columnCount" format="integer" />
<!--当前关1开始-->
<attr name="itemPosition" format="integer" />
<!--解锁文字颜色-->
<attr name="itemUnlockTextColor" format="color" />
<!--未解锁文字颜色-->
<attr name="itemLockTextColor" format="color" />
<!--解锁背景颜色-->
<attr name="itemUnlockBackgroundColor" format="color" />
<!--未解锁背景颜色-->
<attr name="itemLockBackgroundColor" format="color" />
<!--内部左间距-->
<attr name="InnerPaddingLeft" format="dimension" />
<!--内部右边距-->
<attr name="InnerPaddingRight" format="dimension" />
<!--内部上间距-->
<attr name="InnerPaddingTop" format="dimension" />
<!--头像资源-->
<attr name="itemHeadSrc" format="reference" />
<!--头像大小-->
<attr name="itemHeadSize" format="dimension" />
<!--头像边线颜色-->
<attr name="itemHeadStrokeColor" format="color" />
<!--头像边线宽度-->
<attr name="itemHeadStrokeWidth" format="dimension" />
<!--头像箭头颜色-->
<attr name="itemHeadArrowColor" format="color" />
<!--头像箭头上间距-->
<attr name="headArrowMarginTop" format="dimension" />

使用

GameStageView game_stage = findViewById(R.id.game_stage);
//头像资源
game_stage.setItemHeadSrc(R.mipmap.ic_head);
//关数
game_stage.setItemCount(26);
//已闯关数
game_stage.setItemPosition(13);
//Item点击事件
game_stage.setOnGameItemClickListener((position, lock) -> {
    Log.e("Game", "position=" + position + ",lock=" + lock);
});
//头像点击事件
game_stage.setOnGameHeadClickListener((position, lock) -> {
    Log.e("Game", "position=" + position + ",lock=" + lock);
});
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值