is it possible to integrate cocos2d with Normal iphone or tabbarcontoller application?bcos I want to ingrate animation of cocos2d with tabbar application?
You don't need multiple EAGLViews. You just need to add the UIToolbar as a subview of the openGLView of CCDirector. Then make sure your Cocos Layers have are vertical offset so they don't overlap.
Yes it's possible if you tweak a bit cocos2d in order it can manage several EAGLViews (so far there is only one eaglview).
[edit] Managing several opengl views is not the only method (it's case 4 in the doc below).
Flower Garden (appstore game) merges uikit and opengl layers (it's not made with cocos2d but it doesn't change anything to the problem, it's EAGLViews on top of UIKit). They've published an excellent presentation here :
http://gamesfromwithin.com/wp-content/uploads/2010/03/GDC10_uikit_opengl.pdf
Related
I am developing a game for iPhone and I came across a question whether this can be done using UIAnimation or I have to switch to OpenGL.
If you see the picture above, you can realize there is a rectangle (it will have background image) having many holes in it. User is supposed to touch on holes and initiate the animation. The holes are actually on the image and are not some view. Do you know any article or tutorial I need to read in order to understand this can be done using UIAnimation?
It's more like chess. When you tap a hole, there is a view placed and moved at z-axis and then when you press the other hole, the view is moved to that hole and so on.
I believe it can be done with UIViews too. The holes can be made by using an image with "transparent" holes in it. You can place this UIView on top of a background image(if required). When touches are detected, you can animate another view on top of this view using addSubview:. You can keep this other view outside the screen bounds initially so that the animation seems like a sliding animation.
yes UIView is also an option in your case. if you feel that you will use high quality lots of graphic and will do lots of animation stuff at once on the screen, openGL will be the best or perhaps the gane you are making is a 2d game so you must consider COCOS2D "http://www.cocos2d-iphone.org/" for kick starting your game you'll surely get many effects and other glittering stuff with it. and bes of all it is openGL based..!! Performance will be too high for you..!!
Best of luck..!!
Im looking for some sort of SDK or library on top of iOS, which might help me produce iPad/IPHONE games.
The sort of functionality Im looking for is..
GUI elements, skinnable buttons, lists, dialog boxes etc
Any routines to help with tile based games
Functions to paint and move sprites
Any vector libs to help with rotation, skew etc
Im confident I could write all this from scratch, but Im guessing theres some libraries already out there. Im not afraid of getting my hands dirty in code, so please dont slate me for asking for prebuilt stuff :)
Thanks
The defacto answer is cocos2d. Open source, MIT licensed, sprite library (including tiling map support baked in).
As for UI - Cocos has some helper utilities for dealing with UI elements, however its not very hard to skin UIKit (though the more customization you do the more drawing code you end up with).
most of the bits are already available in UIKit, but http://www.cocos2d-iphone.org/ is a framework worth looking at for game dev.
Two notes about cocos-2d:
- cocos has its own implementation of UI control called MenuItem. It can be used to easily emulate the behaviors of Buttons. There is also a simple layout algorithm to dispose this items in columns, rows, grids. There are also other controls that allow you to display text on the screen (labels). No text editors though, AFAIK.
- cocos can be easily integrated with the rest of UIKit, so it is simple to show standard "message boxes", some UIKit elements on top or behind it. I was able to use the cocos view as the child view of a UIImagePicker, for example.
I get how to do a 1 screen opengl view.
But....
How about multiple opengl(1.1) view(s) for a game or drawing program?
For example:
After the drawing program starts up and someone does a 3 finger touch, it would bring up a toolkit of sorts on the top third of the screen for making drawing adjustments.
Or a game that has an animated splash screen the going to the actual game. Info button and other choices done in opengl as well.
The main point being I want to do all in opengl and need to know how to do multiple opengl views.
Thanks for any advice!!
It's not hard to implement multiple OpenGL ES rendering surfaces, you simply need to create multiple views that have CAEAGLLayers backing them.
Generally, multiple OpenGL ES layers are not recommended for performance reasons. You generally want to have one opaque fullscreen OpenGL ES layer for all of the content that needs this. Anything you can render in multiple contexts should be able to be drawn in a single one.
However, all of the things you describe can easily be done using standard UIViews and Core Animation. Overlaying UIViews on opaque OpenGL ES content only leads to a ~5% reduction in rendering framerate in my tests, which I consider perfectly acceptable. This is what I do in Molecules, and you can check out the code for that application to see how straightforward it is to layer these controls on top of OpenGL ES content.
I'd recommend going this route, because re-implementing buttons and other UI elements will take far more code in OpenGL ES than just using the native controls. You'll be sinking a lot of time into reinventing the wheel that could be used to improve other areas of your application.
I would suggest don't use multiple views too. Instead, just set your viewport differently each time and draw with a different LookAt position.
In case this is possible, it would be nice to see some examples!
Thanks,
rui
This question asks something very similar, and as I state there it's trivial to have OpenGL ES content coexist with UIKit controls. The OpenGL ES content lives within a CAEAGLLayer that backs a UIView, which is part of the normal view hierarchy. You can easily overlay other UIViews on top of it.
For an example of this, you can look at the source code to my Molecules application, where I place two UIButtons on top of my OpenGL ES view.
In my benchmarks, you lose ~1-5% of your OpenGL framerate by placing other views on top of the OpenGL ES view, which is not too terrible. What you don't want to do is make your OpenGL ES context non-opaque and try to overlay that on top of other view elements, because you'll see a significant drop in rendering speed then.
Yes, it's possible, after all OpenGL ES context is inside just another UIView subclass. Thing is that Apple doesn't recommend mixing Cocoa Touch objects and OpenGL ES views due to huge performance degradation.
I'm pretty new to the iPhone platform, so I'm wondering what the best way to switch between OpenGL rendering and a UIView might be?
Any comments much appreciated!
There's no need to switch modes at all. OpenGL ES rendering on the iPhone is done in a CAEAGLLayer Core Animation layer. This can be used as the base layer for a UIView, which means that you can combine all the UIView layout and touch handling with your 3-D rendering. This UIView can be fullscreen or placed anywhere on the display. UIViews also can be made subviews of your 3-D view, therefore they can appear above your rendering.
The OpenGL ES Application Xcode template gives you an OpenGL layer within a UIView instance and is a good place to start. For a more complex example, I can direct you to the source code for Molecules, my 3-D molecular viewer. In that application, I use a lot of the view functionality for touch detection and place an info button in the lower right as a subview. I even replace that view with another to produce a flip animation when going to the application's settings.