Cocoa application with cocos2d-iphone? - cocos2d-iphone

I'd like to do this:
Create a Cocoa application with a couple NSButtons in it. Also, a "cocos2d-iphone" view running in the same window.
If I trigger the NSButtons, a function is called in the cocos2d-iphone view (not sure where, maybe in the currently running scene?).
Well, I managed to create a new project from the cocos2d-iphone for Mac template, made the window bigger than the cocos2d view, moved the cocos2d view, and added my NSButtons. Now, I am not very sure about how to make the connection I need.. =/

I suggest reading an Interface Builder tutorial. This one is using Quartz, it's not Cocos2D but close enough. Simply assume the Quartz view to be Cocos2D view while you go through the tutorial.
Note that Cocos2D/EAGLView has some issues with NSView objects. In particular you can't add NSView objects as subviews to the Cocos2D OpenGL view, they will simply not be displayed. This is a general problem of the OpenGL view on Mac, and there are solutions/workarounds for this but they unfortunately do not work with Cocos2D. So if you're planning to have NSView objects overlapping the Cocos2D view … well, you can try and if you can make it work, PLEASE let me know how! :)

Related

Somethings wrong with GoogleMap SDK iOS

My app is using both UIkit and cocos2d. After using view with GoogleMap SDK and show cocos scene. xcode show this:
cocos2d: surface size: 0x0
Failed to make complete framebuffer object 0x8CDD
And the screen is black, and can do nothing except restart app.
I have searched so many website, so many people have same problem but no solution for that.
So is it impossible to use Google Map sdk with cocos2d? If not what can I do?
(Before using GoogleMapsdk I used MKMapview, it doesn't cause this problem but it's not as good as GoogleMap)
Google Maps uses OpenGL ES to render the map. Two OpenGL renderers can not be mixed, they both use their own GL context. Specifically on iOS there seems to be little support to run two GL views side by side (let alone on top of each other).
So no, for all intents and purposes mixing cocos2d and google maps on iOS is not possible.

What Qt classess use to make an animation?

I wrote almost every sort algorithm in C++ in console. Now I would like to make it look good, so what classes of Qt should I use to make an animation of sorting algorithms I implemented in pure C++? Im a newbie in Qt ;) tia
You can use QGraphicsItemAnimation to animate graphics displayed using QGraphicsScene and QGraphicsView.
Links:
Graphics View Framework
QGraphicsItemAnimation
Outside of the Graphics View Framework, you can use QVariantAnimation or QPropertyAnimation to drive properties or methods of any QObject derived class. See the Animation Framework docs for more info.
Conversely you can manually configure a QTimer to drive painting updates of a widget and use an increment to drive a QTimeLine.

Scrolling region in cocos2d version 2

I am trying to implement a help screen in my cocos2d game, using cocos2d version 2.0. My screen will have a title bar ("Help") at the top and then the rest of the screen below that is where I want to put a scrolling help section. Ideally I would be able to put both text and images into this help window.
The problem is that cocos2d does not have any functionality like UIScrollView, and from what I have seen doing Google searches, every custom solution I have found seems to have problems with various bugs popping up on various devices.
I have tried these solutions thus far:
CCScrollLayer: http://www.cocos2d-iphone.org/forum/topic/17118/page/3
Scrolling CCNode: http://tonyngo.net/2011/11/scrolling-ccnode-in-cocos2d/
CCScrollView: http://bitbattalion.com/2011/09/uikit-uiscrollview-and-cocos2d/
The closest thing I got to work was embedding a UITextView but that seemed to randomly crash after a few scrolls so it seems unreliable to me.
Does anyone know of a good simple robust solution to this problem? It seems like it should be straightforward but it isn't.
I recommend that you make new class say:(HelpViewClass) and implement it with an UIScrollView and add whatever you want to add on UIScrollView and then you can use this as a child to your layer.
Steps
Make a class - inherited with UIView
Add UIScrollView to the View.
Add Your components to it.
Add this UIView to the HelpLayer.
You can add any UIKit component to the cocos2d Layer by using this
[[[CCDirector sharedDirector] view] addSubView:scrollView];
Note : Remove all UI component when you go back from this HelpLayer.
I think this may help you !

Steps to add a cocos2d scene to a UIView

Can anyone say the steps to add cocos2d scene to a uikit project. I am new to cocos2d and not aware how to add the files related to cocos2d and also please explain where to add the eagl view in the ui files.
And also share a link for adding a cocos2d in a uiview and not the other way round.
Thanks
For my mind, it is not a good idea to mix uikit with cocos2d. Examples of creating eaglview you can find in any of cocos2d templates. Here you can read how to install cocos2d templates.
http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:lesson_1._install_test

cocos2d customize switch

i need to create a switch over cocos2d scene. i can create a uiswitch and add it to scene but
i really interested in cocos2d switch if there is any....
can anyone give me any idea??
If you compile and run the cocs2d test applications included with cocos2d there are several tests that use controls like a switch or a slider. Then you can look at the test files and see how they implemented.
Best way I have been learning cocos2d is by reviewing the test apps.
Also check out these posts for several other useful resources:
https://stackoverflow.com/questions/2293457/cocos2d-resources/4061868#4061868t
Need 2D iPhone graphics designed