安卓画布绘制圆圈并获取触摸事件[英] android canvas draw circles and get touch events

本文是小编为大家收集整理的关于安卓画布绘制圆圈并获取触摸事件的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我一直在尝试制作这样的演示,其中我需要 draw 很多(数百个) circle 形状在 canvas (或任何如果可能的话),

绘制画布后,我需要缩放并移动它 ..

还希望分别捕获每个形状的 单击(触摸)事件 ..

所以我知道我可以获得帆布触摸事件并获得x和y位置并检查触摸哪个圆圈,但我必须画出许多圆圈,并且在缩放和移动圆圈的x和y pos之后绘制许多圆圈,也是更改所以plz帮助我..

给我任何建议如何做到这一点......去的方式.. 或者,如果有任何Android主人已经完成了这样的事情.. PLZ给我代码样本 ..

谢谢大家, 美好的一天..

推荐答案

根据您的要求,您可以使用2个使用一个Android游戏框架,您可以找到这么多游戏引擎检查此线程,或者您可以使用Andengine最佳的2D游戏引擎之一,以便您可以找到许多示例代码.

对于您的要求,请按照 here

来遵循pinchzoomexample

任何进一步的帮助评论我喜欢帮助这个问题的问题.

本文地址:https://www.itbaoku.cn/post/102401.html

问题描述

i have been trying to make such a demo where i need to draw many(hundreds of) circle shapes on canvas(or any other way if possible) ,

after drawing the canvas i need to zoom and move it..

and also want to capture the click(touch) event of each shape separately ..

so i know i can get canvas touch event and get x and y positions and check which which circle is touched but i have to draw many circles and as well after zooming and moving the circle's x and y pos is changes so plz help me..

Give me any suggestion how to do this..the way to go.. or if any ANDROID MASTER have done some thing like this..plz plz give me code sample..

thank you all, good day..

推荐答案

according your requirement you have 2 use one of the android game framework you can find so many game engine check this thread or you can use andengine one of the best 2D game engine in that you can find many example code.

for your requirement just follow the PinchZoomExample from here

any further help comment the question i love to help this prob.