iOS 7 SpriteKit Scrolling Menu? - ios

I decided to jump into SpriteKit to start working on a game and I'm a little stuck on how I would create a scrolling menu (like Cut the Rope or Angry Birds for example) that would scroll through the various chapters in the game. I know that when I used Cocos2D there was a CCScrollLayer that would take the items (such as images or buttons) for each chapter and then create the scrolling layer but I can't seem to find something similar in SpriteKit. I was thinking that I could probably use a UIScrollView, but not sure if that is the best way to go or if anyone has found anything else that would work for this.

I have found that using a UIScrollView works well for me. From an SKScene you have access to the parent view; self.view. From the scene's didMoveToView: method you can add a UIScrollView and remove/hide it from the willMoveFromView: method.

Related

Scroll With Curve Path

In my app there is a menu which will be a scroll of Labels. I would like them to scroll vertically BUT on a arc. Here is an example:
http://s777.photobucket.com/user/appbeast/media/Applets-Favorites.mp4.html
I have created a demo, but its working on dragging up and down. not working while scrolling. I am sharing my demo code also. Demo Code
Any help will be appreciable guys.
Have you take a look at this tutorial? Rotating wheel control
Maybe yours is a special case 😉
better use collection view or tableview... and then transform cell according to visible index to give the effect of scroll...
https://github.com/bharath2020/UITableViewTricks
One of Apple's WWDC lectures, I think this one: https://developer.apple.com/videos/play/wwdc2014/235/ Advanced Scrollviews and Touch Handling Techniques covers using a UIScrollview's gesture recognizers in your own views to get the same touch and deceleration behavior that users have come to expect. The example had views moving in an arc, but it was an OpenGL 3D arc, like a carnival carousel.

uiscrollview multiple uiview with zoom

I'am working on an iPad application which can visualise network graphs with nodes and edges. This have I accomplished by using an UIScrollView and added UIViews as subviews for the nodes and CAShapeLayer as edges. This works ok with panning and tapping on nodes and uiscrollview, but now I want to implement zooming. This is where my problems begin. How am I supposed to use the UIScrollView with multiple UIView that should zoom in or out according to pinching? How should I limit the zooming to fit the UIScrollViews content size?
I have managed to create a structure as following:
Where the View under the scrollview function as a content view.
I add subviews to the content view programmatically so it would look like:
View
Scroll View (UIScrollView)
View (UIView)
>> Node1 (UIView)
>> Node2 (UIView)
>> Node3 (UIView)
The nodes works fine and can be dragged around. The problem (just to repeat my self) is that I can't control the content view according to the uiscrollview. I have tried to implement pinch gesture which works, but jumps up every time you begin a pinch. Further I have tried to implement a pan gesture but it will only work on the scrollview not on the content view.
I hope you guys can understand my problem. If you could help me to understand the structure of the views and where I should use gestures for pinch and panning I would really appreciated.
Actually, I am begining implementing some similar graph handling visualization.
I Assume, that solution will be a little more tricky, than simply uiview with nodes.
I think, there will be some OpenGL handling panning, taping and zooming in-out. - something with SpriteKit or SceneKit, i guess. I have seen he video from WWDC 2012, 2013, or 2014 - I don`t remember, where they showed how to deal with OpenGL and scrollviews.
Or it will be scrollview only to recieve touches, and some other view to handle animation for theese touch-drag-pinch events.

Proper way to imitate infinite view and animate it on iOS

I'm working on a control that looks like a wheel and is used for fast or precise scrolling of content. Here's an example from coach's eye app:
My first take looks like this:
Currently the vertical lines are implemented as set of UIViews. Sure enough these vertical line views could be easily replaced with image views to customise the look.
Each time user pans:
I modify frame.origin.x on all of the vertical line views
If some of the views go off screen - I remove them
If there's a gap on the left or on the right I create new views to fit the place
When user finishes the pan gesture, I start repeat NSTimer (with like 0.05 of a second) to animate decelerating of wheel movement. On each loop of timer in a nutshell:
Calculate distance to move lines and move them
Calculate velocity deceleration amount and adjust the velocity
A couple of questions:
Are there any iOS frameworks (e.g. CoreGraphics, CoreAnimation, UIKitDynamics) that are suited better for implementing these tasks than UIKit APIs I have used?
Can you suggest a better / more correct way to implement "infinite scrolling wheel" control ?
Can you suggest a better way to implement deceleration after user finishes panning the wheel?
Thanks
I had made my "infinite scrolling wheel" control by customizing SSRollingButtonScrollView. I think you should look at it once. I hope it will help you.
Apple already have a nice algorithm implemented for acceleration and deceleration - in UIScrollView. And you can use that, behind the scenes, to control other views / interaction. This is enabled by connecting the pan gesture from the scroll view to another view and acting as the delegate of the scroll view.
Check out the Enhancing User Experience with Scroll Views WWDC video for guidance.

Scroll in spritekit game

I am building a spritekit game with 2 screens. Inside the 1st screen the player should pick one Hangar out of 6-7, by horizontal scrolling. When one picked a new SKScene will appear with the actual game play. For scrolling - One Hangar should be centered, while two others are partly shown from the sides.
Can it be done with UIScrollView, on top of SKScene? Or better use sprite nodes for it?
I am just not sure about the best way to handle user interface with sprite kit.
I would implement this by putting the hangars as children of a SKNode. Swiping would move this this SKNode move around with all it's children.
If you wanted the positioning you described; when the swiping has stopped I would use an SKAction to center a the hangar closest to the middle of the screen.
I would do it like this because I think you should only mix in UIKit when necessary because :
It is easier to port to OSX
You don't have to convert between different types of coordinate systems

SPTween freezes when dragging/zooming a view inside UIScrollView

I am using Sparrow framework. I have been playing with moving sprites around using SPTween and SXParticleSystem. The problem is when I move or resize a view inside UIScrollView, those tween and particles just freeze. When I end dragging, the sprite moves again, not from where it froze but they move from where they should be if it weren't frozen. How can animate those sprites along side with other animating UIKit elements.
I did try to use CoreAnimation (UIView animation) and drag the scrollview. It doesn't freeze. Any ideas?
CADisplayLink OpenGL rendering breaks UIScrollView behaviour
Animation in OpenGL ES view freezes when UIScrollView is dragged on iPhone
I have seen these similar post above and they suggest that the moving the scrollview changes the runLoopMode to one that OpenGL doesn't normally use. But I still don't know how to change the runLoops in Sparrow framework.
View full size
Solution found. In SPView.m line , change NSDefaultRunLoopMode to NSRunLoopCommonModes. The reason is the default OpenGL rendering in Sparrow is registered using NSDefaultRunLoopMode, which that mode will stop running in some circumstances such as a UI update. For more info, please read the link below.
What are runloops and what modes can we use?
https://stackoverflow.com/a/7223765/467588

Resources