简体   繁体   English

在Android游戏中捏缩放/双击手势

[英]Pinch zoom/double tap gesture in an Android game

I'm currently creating a game (Gomoku) where user needs to input his moves to a square grid of 15x15. 我当前正在创建一个游戏(Gomoku),用户需要将其移动输入到15x15的正方形网格中。 I don't have much experience with GUI so I thought a good way to do it would be to create a lot of ImageViews, corresponding to each individual square, that would change the background picture from blank to X or O when a player moves. 我对GUI没有太多的经验,所以我认为一个好的方法是创建大量对应于每个正方形的ImageView,当玩家移动时,它将背景图片从空白变为X或O。

However, this would be very hard in some cases (finger too big and/or screen too small), so I want to implement a pinch to zoom or double tap to zoom feature. 但是,在某些情况下(手指太大和/或屏幕太小),这将非常困难,因此我想实现双指缩放或双击缩放功能。

My questions is: is it possible to implement such feature to a ViewGroup where it would magnify all the Views within it? 我的问题是:是否可以将这样的功能实现到可以放大其中所有视图的ViewGroup? If yes how, else is there another way to go about implementing GUI for this game? 如果是的话,那么还有其他方法可以实现该游戏的GUI吗?

A canvas would be a better option. 画布将是一个更好的选择。 It would allow you much more flexibility and the graphics can be updated. 这样可以为您提供更大的灵活性,并且可以更新图形。 you can add multiple images and make up the grid in canvas. 您可以添加多个图像并在画布中组成网格。 You can also add multitouch easily as seen on http://android-developers.blogspot.in/2010/06/making-sense-of-multitouch.html 您还可以轻松添加多点触控,如http://android-developers.blogspot.in/2010/06/making-sense-of-multitouch.html所示

As a matter of fact I'm also developing a Gomoku for Android, well, kind of. 事实上,我也在为Android开发Gomoku。

I'm drawing directly in the Canvas of a custom View, as Alok has also suggested. 正如Alok所建议的那样,我直接在自定义视图的画布中绘制。 You may also use a SurfaceView if needing animations and fluid movement, or even OpenGL for the sake of portability. 如果需要动画和流畅的运动,也可以使用SurfaceView,或者出于便携性考虑甚至使用OpenGL。

Regarding zoom, I've not implemented pinch to zoom, just double tap. 关于缩放,我还没有实现双指缩放。 Why? 为什么? Sorry for not being more techincal, but sometimes when pinching "weird" things would happen, messing with the scroll and square selection. 抱歉,没有提供更多技术支持,但是有时在捏“怪异”时会发生事情,从而使滚动和正方形选择变得混乱。 It's also easier to play with one hand. 用一只手玩也更容易。

Offtopic: good luck with the artificial intelligence, it's quite hard to make it strong enough. 题外话:人工智能带来的好运,很难使其足够强大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Pinch Zoom Gesture android - Pinch Zoom Gesture android 在android中双击放大和捏合放大ImageView - Double-tap to zoom and pinch to zoom on ImageView in android Android WebView使用setWideViewPort,禁用双击缩放但保持捏缩放? - Android WebView use setWideViewPort, disable double-tap zoom but keep pinch zoom? 如何为Android测试生成缩放/捏合手势 - How to generate zoom/pinch gesture for testing for Android 使用双击和捏合放大android时如何使谷歌居中? - How to make Google make in center when using double Tap and pinch to zoom in android? ImageView-实现与ViewPager兼容的手势(捏缩放,双击)(就像Android Gallery一样) - ImageView - implementing gestures (pinch zoom, double tap) compatible with ViewPager (just like Android Gallery) 需要捏一下才能缩放,但不能在我的触摸监听器中双击 - Need to be able to pinch to zoom, but not to do a double Tap in my touch listener 双击:放大Android MapView? - Double tap: zoom on Android MapView? 我们可以在 Android 中使用缩放手势检测器进行缩放吗? - Can we use scale gesture detector for pinch zoom in Android? 如何使用Android Monkey工具生成缩放手势? - how to generate zoom/pinch gesture using Android Monkey tool?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM