Archive for August, 2010

Cocos2d on iPhone

Today I took the liberty of looking into Cocos2d on the iPhone. At first it seemed like something uninteresting, but after looking closer, I saw a lot of cool features.

Found at www.cocos2d-iphone.org, Cocos2d for iPhone is a 2D OpenGL wrapper, written in Objective-C. Cocos2d has an assortment of built-in tools, such as: menus, animations, transactions, effects, multi-view support, online scores, and more! Cocos2d provides anything a game developer could need, and more, to an Open Source class library for the iPhone.

Along with box2d (a c++ based physics engine) Cocos2d is the perfect tool for writing games for the iPhone. In the future I may find myself using Cocos2d for apps that I make, instead of using CoreGraphics and CoreAnimation. While Cocos2d is great for 2D, pure OpenGL is still your best option when it comes to 3D graphics.

Pascal Programming on Mac OS X

As a person who is relatively new to program, I never had time to check out older programming languages like pascal and fortran.  Since languages like this have relatively no use in modern times, I figured that I wouldn’t bother looking around for tutorials, compilers, etc.  Today I had a bit of free time on my hands and decided to check out Free Pascal, an open source, modern build of Pascal.

Object-oriented pascal is not as primitive as I imagined.  With loops, conditionals, procedures, etc, pascal is practically C without pointers, memory management, header files, etc.  Check out Free Pascal at www.freepascal.org or download it for Mac OS 10.6 at ftp.freepascal.org. Installation is simple and it’s well integrated with Xcode.

Locare 1.2 Accepted to the App Store

Apple recently accepted version 1.2 (the second version) of Locare, our three cup game. The classic street magician scam was posted to the app store months ago with tons of glitches, and only now was fixed. There was also a simple spelling error when you lost a game. Future updates will be intruduced that provide high-resolution images for the iPhone 4.

OfficeMaster Rejected From App Store

OfficeMaster (aka OfficeGod), our desktop emulator for the iPhone, has been declined for sale due to “Copyright Infringement”.  In the email apple sent back to tell us why OfficeMaster could not be submitted, barely any information was given on what material we copied.  The email’s contents is as follows:

Dear Jitsik,

Thank you for submitting OfficeMaster to the App Store. We’ve reviewed OfficeMaster and determined that we cannot post your application because it appears to include features that resemble Polaroid photographs. Polaroid has previously objected to other applications that include features that resemble Polaroid photographs, and believes that such features infringe its rights.

Please remember that pursuant to your agreement with Apple, you represent and warrant that your application does not infringe the rights of another party, and that you are responsible for any liability to Apple because of a claim that your application infringes another party’s rights. Moreover, we may reject or remove your application for any reason, in our sole discretion.

Please provide documentary evidence that you have the rights to use this content to ensure compliance with the iPhone Developer Program License Agreement. Once Legal has reviewed your documentation and confirms its validity, we will proceed with your application review. Be aware that while your iTunes Connect Application State is displayed as Rejected, it is not necessary to upload a new binary in this particular case. However, if your application is not in compliance, and you are able to make the necessary changes, we encourage you to do so and resubmit your binary for review.

Best Regards,

App Review Team
iPhone Developer Program

I am unclear of what they mean by “features to resemble Polaroid photographs.” No where in my application can you take a photo, and no where can you print that photo. The only photo related thing we have is a desk item that is a picture frame. I did take the picture frame image from the internet, so that may be the problem. I will keep researching to figure out what it is that I may have “Copied”, but for now I am simply frustrated that apple has not told me what part of my app breaks copyright.

If you guys have any ideas on what it may be, shoot me an email at macheads101@me.com.

Hiding Files in BMP Images

Today I was looking into the TIFF image format when I remember something I have been wanting to do for a long time.  I’ve noticed that you can add data to the end of an image file, but leave the image in tact.  I decided today to make a simple app that allows you to add and extract files from the end of a simple BMP image file.

Right now it simply appends information about the file you are hiding to the end of the BMP file, but I may add more clever ways of hiding information in BMP or other image file types.  Future additions to this software may include:

  • Encoding small notes in the line padding of the bitmap data
  • Hiding messages in transparent layers of images
  • Creating images that contain file data directly in the bitmap (e.g every other pixel has a byte of data)

You can check out the Xcode project now at: http://www.jitsik.com/uploads/BMPFileEncoder.zip

QuickTime Encoding on iPhone

Today I continued my search for a good way to encode video on the iPhone.  I turned back to an old QuickTime encoder I wrote for the iPhone.  It encodes raw Bitmap data into a QuickTime container for playback by QuickTime 7, QuickTime X, MPEG Streamclip, and anything else that uses QuickTime.  A problem is that the files are huge.  Yeah, it creates QuickTime files, but without compression, frames really add up.  A 10 second 280p movie with 15 FPS can get up to 25MB.

I am working on writing a version that encodes PNG which should be easy to add to my existing code.  In the mean time I am allowing all my readers to download the source here: Export Test.zip.  The code is not the most organized, but one who is familiar with the QuickTime format should understand some of it.

NSConnection on iPhone?

Today while I was trying to figure out how to use AVFoundation to encode video, an idea occurred to me: “Why don’t I make a server and have that encode the video for me?” I spent around half an hour writing a server for Mac OS X that uses networked distributed objects (e.g NSProxy) to encode video.  I then set out to make a client for the iPhone.  I got the server up an running, but I was unpleasantly surprised to find that the foundation framework on iOS does not have NSConnection anywhere in it.

Although one would call it understandable that the iPhone doesn’t have an unneeded class such as NSConnection, I think it’s completely unreasonable that a class as old as NSConnection is not even available on the iPhone.  I’m sure apple has a million reasons for this, but after spending half an hour for nothing, I am quite frustrated.

Tomorrow I am going to remake the networked video encoding protocol in raw C sockets for maximum compatibility.  Hopefully then I will be able to conveniently encode video on the iPhone using only a couple lines of code, and no raw file I/O.

Video Encoding on iOS

This is an unanswered question I have had for a long time: how do I “edit/compose media” on iOS 4 and later using apples AVFoundation?  I saw in their documentation they specifically have an AVAssetExportSession class, an AVMutableComposition class, etc.  When I read the documentation, the whole export process looked reasonable, but I still couldn’t figure out how to get UI/CG images in the asset/composition as frames.

I’ve worked with the AVFoundation framework before, and it’s my opinion is that parts of it are great (perfectly wrapped in objective-c, etc), but other parts of it simply lack usability.  I am starting to doubt apple’s ability to make easy to use Objective-C libraries lots of things I, as a developer, want to do.

This made me look back to an old AVI encoder I made a while ago for iOS 2.0 and up.  Since AVI is being dropped all together on almost every platform, I really wish I could figure out how to use Apple’s AVFoundation to export video.  I will continue my search, but the path appears unclear when it comes to exporting video on the iPhone.

Check out my AVI encoder.  It is easy to interact with using Objective-C, and allows for sound to be added!  Ignore it’s code though, it’s well obfuscated! XCode Project: ANAVI.zip

Making High-Resolution iPhone 4 Apps

Today, after making a little drawing program in OpenGL (yes, that’s how bored I was), I decided to look into making my applications for iPhone 4 take advantage of the retina display.  I was surprised to find no option in Xcode 4 (developer seed) to make an iPhone 4 specific application.  Instead, there is only an option to make your app for iPad, or for iPhone.

I figured, “maybe I can just set the window size to be bigger in interface builder.” Before I even did that, I decided to do a few tests.  I have realized that some of the apps I have on my iPhone 4 are not made specifically for the retina display, but still have a lot of graphics that look full-resolution on it.  To run a test, I made an app with the iPhone 3GS and earlier screen size (320×480) and put an assortment of UI controls on it using interface builder.

When I ran the application on the iPhone 4 simulator, I was pleased to find that all of the components were full 640×960 resolution.  I then ran another few tests to find that iOS 4 on the iPhone 4 is quite good at determining the best way to make things sharp and perfect on the retina display.

Another cool thing that I noticed is that a lot of my apps use large images, and simply scale them down to fit a rectangle on the iPhone’s display.  Although their coordinates are the same, when I use UIKit to draw them, they are automatically drawn at 4x the resolution (if possible).  This means that apple most likely draws their UI components at full resolution, and translates their bounds and origins when my code asks for them.

I found that the following methods of drawing graphics were automatically transformed for the iPhone 4 by iOS but still functioned perfectly on both the iPhone 4 and the iPhone 3G:

  • Core Graphics calls (gradients, arcs, images, etc)
  • UI components (UIImageView, UIButton, it’s all there)
  • Fonts (drawing text with Quartz or UIKit)
  • CoreAnimation rotations and scales
  • UIKit Keyboard (goes without saying)

I will continue to explore the ways to take advantage of the iPhone 4′s retina display, but for now I am simply amazed at the wonderful job apple has done making the retina display effective for every app.

iPingPong 1.1 Accepted by Apple

Last summer I had a lot of free time on my hands. At one point I decided to make a little app every day. The app didn’t have to be anything someone would use, but it had to have a purpose, and it had to work. The only app I made that I even bothered posting to the App Store was iPingPong. I made this app in about an hour one a hot sunday after going swimming. The app was a simple multi-player pong game, designed to use only apple’s UI components and still be usable.

A couple months ago I looked at my iTunes sales and realized that iPingPong gets a lot of downloads every day. It gets enough downloads in fact that I might have made significant money off of iAds if they had been around back when I posted it. I just last week added iAds and improved the usability of the app, then posted it to the App Store. Today I am pleased to announce that it has been accepted by apple and is available for download on any iPhone or iPod Touch running 4.0 or later.

If you have a couple hours on your hands and can’t figure out something better to do, check it out on the App Store and leave a review at: http://itunes.apple.com/app/ipingpong/id333253449?mt=8. I would love to hear what I should add to it for my next update [I was thinking a $1 dollar In-app purchase to make it good ;) .]

Return top