I currently need to create a custom scroll view without using UIKit's scrollview in cocos2d.
The best way, I think, is to create a separate layer and then add all my sprites to that layer. But I'm not sure how to receive touch events for all of the sprites. Is there a best way to do this? Thanks!
Have you seen CCScrollLayer? It might not be suitable for you but maybe you can copy the way that it is picking up touches.
https://github.com/cocos2d/cocos2d-iphone-extensions/tree/develop/Extensions/CCScrollLayer
http://www.cocos2d-iphone.org/forum/topic/17118
There's another one here as well, not sure if it's a fork or an independent one:
https://github.com/jerrodputman/CCKit
But I didn't have much success with any of these. The bounce and other parts of the experience never feel right, so I go back to using UIScrollView to handle the touches.
I've been facing the same issue and I found the SWScrollView here:
https://github.com/saim80/Cocos2D-Extensions
met my needs better than CCScrollView. It acts more like the UIScrollView where as CCScrollView is more for paging from what I've seen.
There is a nice framework called CMMSimpleFramework.
http://www.cocos2d-iphone.org/forum/topic/39018
http://www.cocos2d-iphone.org/forum/topic/60354
There are some sample videos, and the link to the repo is on those pages.
One of the classes is a scrolling layer that might do what you need.
To get the sample project to run, I had to comment out some game center authentication handler code that has changed, but after I did that the demo worked fine.
Related
I currently have a UIView, call it (A), that is outsourced out into a 3rd party library.
Pressing onTapGesture physically would be simple, but the problem here is that this (A) is on another view hierarchy, versus the one I have. The reason for this is that I apply transforms to this separate from (A).
Im deciding on delegating a UIButton that will programmatically call the UIView in question's onTapGesture, is there a way to do this?
I do not have access to this 3rd party library's selector for onTap.
This is a very late answer to your question. If you still working on this may be my answer will be helpful or may be someone else will find it helpful.
The gesture doesn't expose its target and action. In this case may be creating a fake touch programatically will be helpful. As you have UIView you can easily get the window of that view. With window find out the x,y co-ordinate and create a fake UITouch event. I also had similar kind of problem and creating fake touch worked for me. This is the link I referred for creating fake touches.
I want to make a vertical scrolling view for the level selector on my SpriteKit game, I don't know if I have to use UIScrollView or make it using the SpriteKit framework. Please if anyone knows the best way to do it and how let me know. Thanks.
You have several options here.
It is possible to integrate UI elements into SpriteKit, but instead of adding children to self (your scene), you would add subviews to self.view. You would of course, work with the view now instead of a scene so theres a different way of positioning elements which you would have to work out. Theres quite a few examples of how to do this, here's one that might help you.
An alternative is using something like Scroll Kit, which helps you integrate a UIScrollView into SpriteKit very conveniently!
Also check out this question which might be exactly what you're looking for. Hope this helps!
I have been only using Xcode 5 for a little while now and I need help when it comes to auto scrolling a UIScrollView. I am using a single view application. I need the screen to scroll down at a pace that speeds up incrementally. Also I need the screen to keep progressing even when the screen is touched. If someone can explain which code goes where it would be great! Your help will be greatly appreciated. :)
Check out this library: https://github.com/danielamitay/DAAutoScroll
It stops to scroll when the user touches the screen and that's the only solution I see possible. I don't even see why you wouldn't want the user to be able to stop the scrolling..
OK, just adding this from your duplicate question.
I suspect the Piano Tiles game is actually using something like Sprite Kit.
This allows a lot more control over thing like "scrolling" speed.
Instead of using a UIScrollView you would use an SKNode as a layer with the buttons added to that parent layer.
Then using the update game loop you can incrementally increase the speed of the movement based on the time since the game started.
In essence... don't use UIScrollView, don't use UIKit, use SpriteKit.
I can see a few options:
1) suggested by Fogmeister, use Sprite Kit instead.
2) see setContentOffset
3) just use a normal view as parent, then have another child view on top with the full content (would be longer than the parent view), create a NSTimer to periodically call a method which scrolls the child view in whatever direction and speed as required.
Note that might need something on top to mask around the child view from showing the suppose-to-be-hidden sections of the child view.
Hope this helps
OK so in my game I need the users to scroll between items, just like you scroll a web page in Safari. Is there any way to do that? If not, maybe scrolling them to the side, like you do in the spriboard? Thanks.
I am not really sure I have understood what you would like to do, but there is a cocos2d extension that seems appropriate to it: CCScrollLayer.
CCLayer subclass that lets you pass-in an array of layers and it will then create a smooth scroller. Complete with the “snapping” effect.
If you are looking for a generic scrolling within your view, I suggest this tutorial or this topic rom cocos2d list.
EDIT:
I have never done it, but I think it should be possible to scale the CCScrollLayer to the size you need.
Otherwise, you might change the contentSize of the layer, or even put the CCScrollLayer into a clipping node.
Anyway, I think that it is much easier to start from this and find a way to adapt it to your specific requirements than start from scratch.
What would be the mechanism behind twitter iPad application? I feel its having split viewcontroller, viewcontrollers with animation and gesture controls, or there may be scrollviews for endless scrolling.
How can I develop same UI for my application?
Hey, here our is a demo project which is inspired by Twitter-ipad app
http://www.raweng.com/blog/stack-scroll-view/
its source code is opensource on githib (link posted in above blog).
hope that help u to understand the concept behind it !!
Matt Gammell ... He did a draggable split view. Its the closest i can think of may be configurable to emulate that http://github.com/mattgemmell/MGSplitViewController
I believe it is just a scroll view with enabled paging, that moves it's subviews on scrollViewDidScroll, does some additional animation in scrollViewDidEndScrollingAnimation method and with some other slick and sexy things :)