Drag/Swipe to scroll the screen - xna

What would be the best way to have a vertical scrolling screen? My game will consume two screens high, the user should be able to move between the two screens by a simple drag or swipe action. The background is not tiled and sprites will be placed on it. What would be the best way to go about such screen management?

You have asked two questions here. The fist of which is how to respond to touch gestures (like a swipe). This blog post and associated sample is a good starting point.
The second of which is how to have two screens. This is also simple. Pass a translation matrix (Matrix.CreateTranslate) into SpriteBatch.Begin. How you want to do this is up to you. If you want both screens to have (0,0) be the top left of the screen, give each of them a translation matrix and translate one downwards by the display's height below the other. (While a screen is out of view, you could skip drawing it entirely.)
When the user swipes, simply animate the translation such that one screen moves out of view, and the other moves into view.

It depends on whether you want users to be able to see half of the top and half of the bottom screen, or only ever the top or the bottom.
You could try placing the two screens worth of content into a ScrollViewer, and setting the ScrollViewer.VerticalScrollbarVisibility to False; this would allow users to drag/swipe easily between the "screens".
Something like:
<ScrollViewer VerticalScrollBarVisibility="Hidden">
<my:FirstScreen/>
<my:SecondtScreen/>
</ScrollViewer>
One thing to consider would be whether you want to handle the user changing the phone orientation, or whether you'll lock the phone into Portrait/Horizontal orientations. I also believe that phones with different resolutions will eventually be released and any applications in the Windows Marketplace will need to be able to handle both full and half resolutions.

Related

Create Horizontal ScrollView

I want to know how to create a horizontal scroll view in Swift. I also want to know how to add buttons to the scroll view. An excellent example of what I'm essentially asking for is in the game "Cut the Rope."
In the picture you're presented with a picture (which you can click on) of a "fabric box." There are other different types of boxes that, with scrolling, you can access them. How would I do something similar to this?

Circular scrolling in iOS that follows your finger?

So I am trying to figure out how to make a circular scrolling system. So I have for example a wheel like this http://static.cubiq.org/uploads/2009/04/Rotating-wheel.jpeg and you scroll between options (like an old school ipod) Now I currently already have this working with positions. So I have positions 1-6 and as you scroll down, it moves everything down a position and I animate this transition. I am wondering if there is a way to do this using the actual scroll function. So that you can scroll up and down freely while holding down, rather then doing up or down actions and waiting for animation.
So given that information how could I convert a standard vertical scroll up->down and down->up into a circle structure. Thanks for any info

Changing VoiceOver's scrolling/paging distance on a UITableView

I have a screen in my app that consists of a UITableView with another opaque view overhanging on the top (which is also interactive). The content offset is set correctly such that the entire tableView is visible to a sighted user.
However, when using VoiceOver and paging up/down with three fingers the default scroll distance will place part of the tableView under the overhanging view, and thus prevent VoiceOver from reading part of the tableView[1].
Is there any way to change how tall a "page" is when using VoiceOver?
[1]: I know that there are still ways to cycle through all the elements, etc, but it's far easier and more discoverable for partially sighted users to skim over elements with their finger.
I think you are looking for this: https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIAccessibilityAction_Protocol/index.html#//apple_ref/occ/instm/NSObject/accessibilityScroll:
Re implement that method and scroll the amount of pixels you require instead of a whole page

iCarousel – Make all items selectable, not just centered one

I'm using the great iOS control iCarousel's Wheel type and I want all of the buttons it contains to be usable / selectable at any time (i.e. I can tap any of them, no matter which one is currently at the top of the wheel). The user can still scroll the wheel as normal, but no matter which button they tap, it should register.
The current behavior seems inconsistent: if I tap one of the buttons directly next to the center one (to its left or right), that button moves into the center slot. Clicking one of the buttons two positions away 'sometimes' causes it to scroll to that letter, sometimes it's ignored. Any other buttons are always ignored.
Is this possible to set up, preferably without hugely modifying the class? I'm by no means an expert, but am learning every day :)
Thanks in advance.
Set carousel.centerItemWhenSelected = NO;
That will disable the behaviour where buttons other than the centre one are scrolled to the centre when you tap them.
As for the reason why some are not responding to taps at all, it is most likely because the frame of your carousel view is too small and the tap events are outside of the frame.
If you set carousel.clipsToBounds = YES; it will crop the carousel views to the frame as well so you'll be able to see exactly what size your carousel actually is.

Draw animations dynamically (interactively) on MKMapView

I want to draw an animation over MKMapView. I want it to be something like a compass arrow, that follows (rotates) user's taps / swipes .
So the arrow goes from the center of the screen and is of a fixed length. I don't need the line to be coordinate-specific, but I need to keep the map interactions intact (i.e. still being able to pinch-zoom on the map).
I tried to do that via MKPolyline (creating and then destroying a line), but that does not work (and from the way I had to do that I feel like it won't work). I wonder what would be the best way to handle that? Quartz?
I would accept just an explanation (which kind of view overlay over what, which classes to use), no code is necessary (but if you have a working example that's so much better ))
I draw views like a map ruler not as subview from MkMapView. I put kMapView and my ruler view into a container view. This works for views which positions are fixed on screen, like on center of screen, and are not related to a geographical position.

Resources