I'm planing on making an utility app that could help people create table plans for sitting guests.
The thing is, the only way I see this is by letting users create first their own room, with the correct number of tables and sits, then populate the room with the guest list.
But to do that, I was thinking on using the Sprite Kit technology, because it seems to be an quick and easy way to make 2D schemes, use sprites and rely on coordinates.
Here comes the questions :
Is it possible to make an utility app with a "game" core ? Would Apple allow me to do so ?
If Sprite Kit is not an option, and regarding the fact I'm actually working on xcode 6 + Swift, what would be the alternative to make this process of letting the user create a room that uses X,Y coordinates?
I hope I'm clear, if you have any questions, I'll be happy to complete my requests. Thanks folks !
Nicolas
It depends on the design of your application and what it's requirements in terms of user interface. With SpriteKit, many of the interface elements provided by UIKit are not available and you'd have to build your own if you wanted to use SpriteKit exclusively.
However, there is nothing stopping you from also using UIKit for certain elements such as a UITableView, but it would be a separate view and input would need to be handled via UIKit system. With SpriteKit you don't have a bunch of UI elements to work with.
SpriteKit would mainly be most useful if you need animation and game-like functionality in your utility app.
Apple wouldn't restrict you from using SpriteKit for any kind of app.
In terms of an x,y coordinates, any element you create via SpriteKit or otherwise is going to allow you to position it in that way.
From SpriteKit programming guide, first sentence actually:
"Sprite Kit provides a graphics rendering and animation infrastructure that you can use to animate arbitrary textured images, or sprites."
That is what makes it ideal for games, however not limited to that.
Related
I'm building an iPhone core motion game demo and would like to have a virtual "room" around the user. The user would be using the phone with the core motion to "look around" the room through the phone. Attached is an example.
I'm not looking for anything fancy. 4 solid color panels for walls and 2 panels for the floor and ceiling would do. Pretty much a large cube with the middle at the user's location
What is the quickest way for me to create a room with a box geometry, putting the user in the middle? Can this be done with UIKit objects, or do I need to use openGL to render the panels? Maybe there's some kind of a game engine that I can use for these purposes?
I would want to rotate the room in the future.
Thank you for your input!
You won't be able to create a 3 dimensional environment without using OpenGL in some form. The best way to get started is to follow a good tutorial on OpenGL such as this one. You could even take this tutorial and put the camera inside the cube and voila, instant room. You would just need to add view rotation logic from core motion and you would be set.
If I was interested in getting across game development on the iPhone/iPAD any suggestions on which technology(s) to start looking into? In fact just a simple bullet on each of these technologies that highlight how it fits into typical game development would be great, as the reason for this question was me not understanding how these fit together. So in this case it's where do these roughly fit in here:
UIKit
Core Animation
QuartzCore
OpenGL
cocos2D
I was getting the impression that cocos2D would be the way to go, and it seems to be a simpler wrapper for OpenGL? Not sure where that leaves UIKit vs Core Animation vs QuartzCore then?
Ok well I will try to make a rather lengthy answer short: it depends.
Now for a few longer thoughts and explanations - this is long. If you won't read it to the end, make sure you read the last few sentences.
First I need to clarify that the "technologies" or API's you have listed are mostly concerned solely with graphics
(except UIKit which also handles input) and that is ok as long as you understand
that the graphics is only a part (and as of my experience I might add "minor") of
a whole game.
Besides the graphics, there will be quite a bit more to handle when doing a real game.
In order not to get a away from the question too much let me just throw in a few buzzwords:
game logic, AI, resource management, physics, interaction, networking (possibly), sound, etc.
My recommendation is to get a good book on the topic and dive in [1,2].
Now that I skimmed that, back to your question:
Basically, OpenGL and QuarzCore are the core technologies to "get something drawn on the screen". All other technologies are built on top of that. So in theory, if you want to go that
way, you can implement everything related to graphics output with OpenGL or QuarzCore alone (whereas you will have to account for the fact that QuarzCore is 2D drawing only, whereas OpenGL supports 3D also and 2D is really just a special case of 3D). I actually believe that Quarz is also built on top of OpenGL, but I'm unsure about that.
UIKit is built on top of those and using it does basically two things: a) avoid re-inventing the wheel and b) make creation of user interfaces easier, faster and more robust. Of course you could draw every button itself by specifying the coordinates of a quad and sending that to OpenGL for processing. Then you would have to check every user input if it hits your button and call an associated handler. However, just creating an UIButton instance (maybe even in IB) and specifying an on-click handler does remove quite a lot of work.
Bottom line: UIKit is perfectly suited for creating user interfaces. Plus it can be used together with OpenGL and QuarzCore. I use it for the user interface on iOS even in games.
Regarding Cocos2D: This one is a "game engine" built on top of OpenGL. As such it includes quite a lot of the stuff you would have to handle yourself when rolling your own OpenGL-based engine, i.e. scene management, sprites, texturing, meshes, resources etc. I believe it also has connections to physics and collision detection libraries. In order to understand what happens there, however, requires to learn how computer graphics and games work[1,2,3].
Bottom line: you would use Cocos2D for your (2D) game graphics and UIKit to do the user interface.
CoreAnimation then is for animating CoreGraphics stuff. It provides an easy interface, e.g. for smoothly sliding or rotating stuff around, encapsulating all the required calculations (interpolations, redrawing etc). Will not work with OpenGL - but I think Cocos2D will also have a wrapper for that.
Bottom line: Use for fancy user interface animations.
Having said all that and just merely skimming the top I didn't want to frighten you in the first place.
For your special game (and every game is special) you might well get away with just UIKit and CoreAnimiation for the graphics and it might well make a blockbuster game. They allow a lot of drawing to take place with an easy to use interface plus they don't require too deep background knowledge and are sufficiently performant for small projects.
If you have a great game idea, use the simplest possible graphics solution that will satisfy you and your players and realize it. Once you got it going, you can still improve it if necessary.
[1]http://www.mcshaffry.com/GameCode/
[2]http://www.gameenginebook.com/
[3]http://www.opengl.org/documentation/red_book/
I have been building a game in cocos for a while now I it has just occurred to me that it might just be a whole lot easier to use UIKit.
Could you please help me weight up the pros and cons, and share some experiences you have.
Here is my basic list of advantages for each. I feel I dont know enought about cocos to make a informed decision which is best.
Cocos
Game engine comes for free. Pause / resume callbacks every frame
Sprite animations
Uses open GL (is this true? is this an advantage?)
...Help me think of some more!
UI Kit
Far more Help / Documentation / Sample Code
Familiar for iPhone programmers
Easy to handel touch
Easy view animations
Easy to customise
Faster loading times? (is this true?)
Any feedback would be great!
EDIT: I have just seen a developer video (on an open GL game called Quest) where they used UI Kit for the UI elements, drawn over the top of the GL View. Is this possible / practical with cocos?
Cocos2d uses OpenGL for drawing its sprites, movements, and particles. Trying to use Quartz/Core Graphics (which is NOT accelerated!) is fundamentally much slower and power hungry.
Cocos2d is a sprite library with a scenegraph first and foremost. You would be duplicating effort to make a scenegraph using UIKit.
There are lots of nice freebies that work within Cocos which you would have to develop from the ground up.
So, in short: It draws way faster than CPU bound drawing calls, it provides 95% of what most sprite based games need without reinventing the same thing over and over, and is free.
Although UIKit is incredibly useful for gaming, Cocos2D offers a variety of easier ways to accomplish many common game-making operations. For instance, it has the ability to create easy scrolling-tile games (very common and very popular) using a simple few lines of code to import a "Tiled" map set. In terms of some of the benefits of UIKit over Cocos2D that you mentioned, they are very easy to accomplish in Cocos2D, as well.
Touch handling:
This is as easy as replacing the "touchesBegan" method of UIKit with "ccTouchesBegan" and setting self.isTouchEnabled = YES in the init method.
Animations:
This is so much easier in Cocos2d, mainly because frame rate and animation issues are solved. In UIKit, you cannot use CoreAnimation to move an object while still implementing collision detection. You would have to animate the object with an NSTimer. In Cocos2d, you can easily animate objects (called sprites) and still use collision detection and interaction with the object.
More Help/Documentation:
Cocos2D offers an incredible amount of documentation and, even more so, examples of code! If you can't find it there, there is a growing number of iPhone game developers who implement Cocos2D in their apps and are willing to help many problems.
If you are planning on developing games for iPhone, and not just general apps for productivity, music, etc., I highly suggest Cocos2D. Remember, you can always still find ways to combine this and UIKit for many operations! Those operations aren't completely lost!
i am building a game which is similar to the Plain Jane Flash Game for the iPad. I have decided to use cocos2d for the same, while exploring the cocos2d there are lots of option i am having. i am confuse in which elements/controls would be best for this type of game Please guide me or share any link/tutorial on cocos2d which have similar user interface.
I mean shall i use CCMenu/CCmenuItem or there is another control which is more suitable...
shall i use Sprite or simple image would be sufficent as i do not need to move anything in it.
Thanks
Although your question was not very clear, I assume your referring to the functionality of dragging and dropping different clothing items onto the game avatars. A custom CCSprite object would be much more appropriate for doing that.
However, there is not an easy answer for what you are asking. Creating a game like "Plane Jane" will involve many problems that I'm sure have not crossed your mind. I recommend you complete a few Cocos2d-iPhone tutorials before you go any further. Once you do that, you will have a much better understanding of the functionality you will need to create your game.
Here is a nice tutorial for starters:
http://www.cocos2d-iphone.org/archives/582
I had an idea for an app that would require me to implement these little sprites that would require basic physics features like gravity, acceleration, etc... so naturally I looked into a game loop for the iPhone, there were plenty of threads on this, but what I am trying to understand is that I want to be able to create these sprites and have them behave naturally using a game loop, but still have full "standard" iPhone interaction, i.e. touches, pinching, swiping, core animation, core data, etc...
Is this just as simple as implementing a game loop on a background thread and updating sprites on that thread then doing the standard operations on the main UI thread (except of course for obvious background tasks)?
I would like some general overview of this type of thing if thats possible.
I wanted the same thing, but the iPhone SDK is all about async and callbacks and it's better to roll with the framework rather than fight it. If Cocos2d does not satisfy you, you could look into hooking into NSRunLoop.
With regards to CADisplayLink: I noticed a drop in performance (decreased triangle throughput) when using CADisplayLink with OpenGL ES (which you have stated you are not using so I will not elaborate further).
In Xcode try creating a iPhone OpenGL ES project. Just build and run with the default code. You should see a box moving up and down. This simple example should give you an insight into animating objects and how the OS version of the device matters. The OpenGL view is based off a normal view that you can attach gesture watchers to.
Check out one of the available game physics engines. Cocos2D is a good place to start: http://www.cocos2d-iphone.org/ -- free and lots of resouRces to get started with.