From c4531a92e866c1edb76245ffc92a0afe4742392b Mon Sep 17 00:00:00 2001 From: hexleo Date: Wed, 3 Aug 2022 16:09:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20src=E7=82=B9=E5=87=BB=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BD=8D=E7=BD=AE=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tencent/qgame/animplayer/mix/MixTouch.kt | 4 +++- .../java/com/tencent/qgame/animplayer/mix/Resource.kt | 6 ++++-- .../qgame/playerproj/player/AnimVapxDemoActivity.kt | 10 +++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/mix/MixTouch.kt b/Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/mix/MixTouch.kt index 381c173a..4b616a4c 100644 --- a/Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/mix/MixTouch.kt +++ b/Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/mix/MixTouch.kt @@ -38,7 +38,9 @@ class MixTouch(private val mixAnimPlugin: MixAnimPlugin) { list?.forEach {frame -> val src = mixAnimPlugin.srcMap?.map?.get(frame.srcId) ?: return@forEach if (calClick(x.toInt(), y.toInt(), frame.frame)) { - return Resource(src) + return Resource(src).apply { + curPoint = frame.frame + } } } } diff --git a/Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/mix/Resource.kt b/Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/mix/Resource.kt index 5e5c4b26..f56f8536 100644 --- a/Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/mix/Resource.kt +++ b/Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/mix/Resource.kt @@ -16,18 +16,20 @@ package com.tencent.qgame.animplayer.mix import android.graphics.Bitmap +import com.tencent.qgame.animplayer.PointRect /** * 资源描述 */ -class Resource { +class Resource(src: Src) { var id = "" var type = Src.SrcType.UNKNOWN var loadType = Src.LoadType.UNKNOWN var tag = "" var bitmap: Bitmap? = null + var curPoint: PointRect? = null // src在当前帧的位置信息 - constructor(src: Src) { + init { id = src.srcId type = src.srcType loadType = src.loadType diff --git a/Android/PlayerProj/app/src/main/java/com/tencent/qgame/playerproj/player/AnimVapxDemoActivity.kt b/Android/PlayerProj/app/src/main/java/com/tencent/qgame/playerproj/player/AnimVapxDemoActivity.kt index b23ad69b..ffa8f190 100644 --- a/Android/PlayerProj/app/src/main/java/com/tencent/qgame/playerproj/player/AnimVapxDemoActivity.kt +++ b/Android/PlayerProj/app/src/main/java/com/tencent/qgame/playerproj/player/AnimVapxDemoActivity.kt @@ -70,6 +70,8 @@ class AnimVapxDemoActivity : Activity(), IAnimListener { Handler(Looper.getMainLooper()) } + private var lastToast: Toast? = null + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_anim_simple_demo) @@ -140,11 +142,13 @@ class AnimVapxDemoActivity : Activity(), IAnimListener { // 注册点击事件监听 animView.setOnResourceClickListener(object : OnResourceClickListener { override fun onClick(resource: Resource) { - Toast.makeText( + lastToast?.cancel() + lastToast = Toast.makeText( this@AnimVapxDemoActivity, - "srcTag=${resource.tag} onClick", + "srcTag=${resource.tag} onClick ${resource.curPoint}", Toast.LENGTH_LONG - ).show() + ) + lastToast?.show() } })