Is it okay to use a UIImageView as a 2D sprite for game development? Is there a better alternative to 2D sprites? Also, I want to do some collision detection, but I have an issue in terms of being able to rotate and translate a UIImageView at the same time. Could anyone give me an example of how one could do both at the same time? The CoreGraphics framework seems to work okay for doing one-time animations, but for game development and trying to implement your own collision detection schemes, it seems kind of difficult to work with, because I essentially want to have an infinite loop for each sprite object that check for collisions, and then adjusts the sprites accordingly. Is that even possible with CoreGraphics?
Edit: At the end of the day, I am making a game that requires blocks to torque around each other, which is why I ask.
NO! UIImageView is not meant for sprite manipulation - your performance will be terrible.
Use OpenGLES to render your sprites. I highly recommend writing your own sprite engine so that you learn all about OpenGL, and the best ways to render spites (keep your draw calls to a minimum, use as few texture pages as possible, and so on), and you'll also learn about graphics-pipeline architecture. All of this is essential if you're serious about writing games.
A lazy alternative is to search for one of the open source libraries on the web, but you won't learn much other than all about the problems and headaches of trying to get a random open-source library to compile in your code.
__________________
Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----
Is it okay to use a UIImageView as a 2D sprite for game development? Is there a better alternative to 2D sprites? Also, I want to do some collision detection, but I have an issue in terms of being able to rotate and translate a UIImageView at the same time. Could anyone give me an example of how one could do both at the same time? The CoreGraphics framework seems to work okay for doing one-time animations, but for game development and trying to implement your own collision detection schemes, it seems kind of difficult to work with, because I essentially want to have an infinite loop for each sprite object that check for collisions, and then adjusts the sprites accordingly. Is that even possible with CoreGraphics?
Edit: At the end of the day, I am making a game that requires blocks to torque around each other, which is why I ask.
I would disagree with the other poster. If you're a beginning developer, trying to learn OpengGL is going to make your head explode. I have been programming professionally for almost 30 years, and it almost made my head explode.
I've done enough OpenGL now that I might tackle it if I was trying to write a game like you describe, but I'd also take a long hard look at libraries like cocos2d that are available.
You can use UIImageViews or CALayers along with Core Animation to do very smooth animation. However, I'm not sure how you'd make that work well for frame-based animation along with collision detection and whatnot.
As far as handling objects rotating around other objects, you're going to need to learn about transformation matrixes. Pretty much whatever route you take, you'll need to tackle those.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
As a fellow 30-years-of-professional-programming-person, I respectfully disagree with you Duncan.
If someone is serious about writing games then it's crucial to learn the basics of how everything works, particularly if your goal is to make that your profession. Yes, perhaps this is my personal preference, but understanding what's going on under the hood (not that OpenGL is particularly far beneath the hood, but it's a start) pays dividends in the future, especially when it comes to debugging some horrible 'random bug that causes the screen to go black and the device to lock up' problem. And to be honest, OpenGL really isn't that tricky to get your head around (especially compared to something like DirectX) - there are plenty of decent books that begin with the very basics and progress from there. I honestly think the effort up front is worth it.
Like you said, the original poster will have to get to grips with matrices, vectors, the joys of dot and cross products, and all the rest of the fun that goes with it, so why stop there?
__________________
Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----
Is it okay to use a UIImageView as a 2D sprite for game development? Is there a better alternative to 2D sprites? Also, I want to do some collision detection, but I have an issue in terms of being able to rotate and translate a UIImageView at the same time. Could anyone give me an example of how one could do both at the same time? The CoreGraphics framework seems to work okay for doing one-time animations, but for game development and trying to implement your own collision detection schemes, it seems kind of difficult to work with, because I essentially want to have an infinite loop for each sprite object that check for collisions, and then adjusts the sprites accordingly. Is that even possible with CoreGraphics?
Edit: At the end of the day, I am making a game that requires blocks to torque around each other, which is why I ask.
It's hard to tell your current skill level. If you have already coded a sprite class in another language such as C++ it's probably fine to just dive in and use OpenGL as the basis but your maths will have to be quite good to understand what's going on. If however you just want to learn the basics then there's nothing wrong with using an array of imageviews & CGRectIntersectsRect to tell if rectangles are overlapping for collision.
So if your maths is good & you have some experience go straight for OGL. IF not consider doing a few tests with views before diving in.
Wow, these have been very interesting responses. I am an engineer, and I have a Bachelor of Science in both Electrical and Computer Engineering from the University of Toronto. That being said, matrices, cross and dot products, array arithmetic, statics, vectors, dynamics...I ate and slept those in school the past five years. I will go down the OpenGL path, and see where it takes me. I do appreciate all of your responses! Duncan, I know how much you've helped me in the past, but I don't mind the challenge. By the way, through your help I finally pushed out an application which should be reviewed some time this week
If you're making a game, I'd look at some third party framework, like Cocos2D that's specifically designed for game development. It also gives you the benefit of OpenGL performance without actually dealing with OpenGL. It has two physics engines built in as well, and it's open source/free. An example of its use is the game Siege Hero in the store.