Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Jessy · Feb 07, 2011 at 05:50 PM · iosiphoneipadgestures

Pinch vs. Rotate gestures: can they be made size/resolution-independent?

I'm trying to come up with a way to detect pinch in/out, and rotation gestures. If you delay the detection of a gesture, and allow some data to be collected for a few frames, I think this would be easy. But in Apple's Preview App, for example, the detection seems to be instantaneous to me.

As far as I can tell, in Preview, the only differences between a pinch and a rotate gesture lie with detecting distances between the positions of the two fingers at the beginning of the gesture. Is that really how the pros do it? ;-) If so, I can't think of a way to make the gestures independent of screen size and resolution the data that we get from the touch positions is in pixels, not units of length. It's no big deal now, but it would be nice if people could still play my games, say, after I die and can't update the code for new devices.

My current idea is to set gesture differentiation differences based on iPhoneSettings.generation, and allow users to set their own preferred threshold in a tucked-away menu. Got any better ideas? :-)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Eric5h5 · Feb 07, 2011 at 07:02 PM

I would suggest normalizing the touch positions. For example (using mouse input to make this a bit more general):

private var screenWidth : float; private var screenHeight : float; private var ratio : float;

function Start () { screenWidth = Screen.width; screenHeight = Screen.height; ratio = screenWidth / screenHeight; }

function Update () { var normalizedMousePos = Vector2(Input.mousePosition.x / screenWidth * ratio, Input.mousePosition.y / screenHeight); }

That way the input coordinates are the same regardless of screen size.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jessy · Feb 07, 2011 at 07:16 PM 0
Share

I think I'm not smart enough to go on just that. :-D

avatar image Eric5h5 · Feb 07, 2011 at 08:04 PM 0
Share

@Jessy: Sure you are. ;) But I edited my answer anyway.

avatar image Jessy · Feb 07, 2011 at 08:47 PM 0
Share

I think that handles resolution independence fine for screens that are the same physical size. But going from iPhone to iPad, or from laptop trackpad to $$anonymous$$agic Trackpad (not possible yet I know), the distance at which a pinch becomes a rotate would become greater. It's not so bad on iOS right now, because I can painstakingly account for all options, but what if I'm interested in putting the game on more devices in the future? $$anonymous$$aybe it's just impossible to make a game that feels right for a whole bunch of devices of slightly different size?

avatar image yoyo · Feb 07, 2011 at 08:56 PM 0
Share

Yeah, you'd also need to normalize for the physical screen size, something like mousePhysicalX = Input.mousePosition.x * screenWidthInInches / screenWidthInPixels. But then you need to deter$$anonymous$$e screenWidthInInches, from generation or whatever other info about the particular device you can find. But it does seem like the gestures ought to be scale-independent somehow, in which case Eric's suggestion makes sense.

avatar image Eric5h5 · Feb 07, 2011 at 09:20 PM 0
Share

Indeed, physical screen size is a somewhat different matter. I think going from iPod/iPhone -> iPad is different enough that ideally you need a different interface for many games and probably shouldn't just scale everything up. Some kind of "Screen.pixelsPerInch" property would be nice....

Show more comments
avatar image
0

Answer by user-12680 (google) · May 12, 2011 at 05:08 AM

I have figured out the simplest solution and this is what Iphone SDK's Gesture recognizers do. pls go through this link.

http://ourinnovativemind.blogspot.com/2011/05/how-to-differentiate-between-rotation.html

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jessy · May 14, 2011 at 02:53 AM 1
Share

I don't understand what's going on there.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to identify each iOS device? 1 Answer

Xcode build crashes 0 Answers

Setting resolutions for iPad and iPhone 0 Answers

Grass Won't Show — Any Suggestions on the Cause? 2 Answers

Prepare Different Resolutions App Preview Videos for Apple Store 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges