i’m so full of ideas

Hearts Net and iOS 7

October 29, 2013 1:57 am

As some of you may have noticed by now, you can no longer play against other people in Hearts Net using Game Center, if you’ve upgraded your device to iOS 7. I know it’s common for iOS apps to be broken by new versions of iOS, but for me, this is a first, which I was not expecting. Multiplayer games may also be affected if you use WiFi or Bluetooth, but I am less sure in those cases. I haven’t done very much testing yet.

Rest assured, this bug will eventually be fixed. But for us developers in the Apple ecosystem, there is a lot of new stuff to be dealt with recently: Xcode 5, 64-bit iOS devices, iOS 7’s entirely rebooted user interface. Hearts Net has never been the prettiest app in the store, but I am at the very least going to do enough work on it so that it doesn’t look completely out of place in the new user paradigm.

I don’t have an estimate on when I can get to all this, because I’m pretty busy at work right now. But you can be sure that Hearts Net will continue moving forward.

UIImage rotation, part 3

July 21, 2012 8:22 am

UIImage rotate test program

My two earlier entries on UIImage rotation are by far the most popular blog posts I’ve ever written. I’m trying to get back into the blogging habit, so here I am, exercising my weak technical writing muscles. And I’ve decided to host my code at GitHub, like all the cool kids are doing these days.

I’ve revisited my UIImage rotation code, cleaned it up a little bit, written a test program that shows various rotation effects, and put the whole thing up on GitHub.

That’s all I’ve got for now. Further bulletins as events warrant.

Installing Xcode 3 and 4 side by side on Lion

March 19, 2012 10:59 am

Xcode 4 sucks so, so, bad. It kills my productivity like whoa. As a consequence, I’ve been doing most of my work in Xcode 3 on Snow Leopard, venturing into Xcode 4 only for testing and final releases. (I am currently working on a code library that’s used by other iOS programmers, most of whom will be using Xcode 4.)

I know I’ll have to update to Xcode 4, eventually. I can’t hold back time forever. But the longer I wait, the more likely it is that Apple will fix all the glaring issues. Until then, I’m going to cling to Xcode 3 for dear life.

Recently, Apple made things a little more difficult for me by releasing a new version of Xcode 4 that only works on Lion. So I had to update my operating system, finally. But I found a way to install both Xcode 3 and Xcode 4 side by side, without any real problems.

My new Lion setup works better than Snow Leopard did in one significant respect: Xcode 3 is now able to install and debug programs on devices running iOS 5.0 and 5.1, which didn’t work for me before. I’m assuming it’s using device debugging stuff that Xcode 4 installed, but I’m not sure. I’m just glad it works, because I use it a lot.

Here’s the steps I took, which might work for you as well.

Step 0: Remove all existing Xcode versions

I’m assuming you are starting from a fresh install of Lion, which doesn’t contain any developer tools at all. If not, the instructions given here probably won’t work. The order of installation is important.

This command should work to uninstall Xcode 3:

sudo /Developer/Library/uninstall-devtools –mode=all

And this one will uninstall Xcode 4:

sudo /Library/Developer/Shared/uninstall-devtools –mode=all

… then remove Xcode.app from your /Applications folder.

Step 1: Install Xcode 3.2.6

As of this writing, the most recent version of Xcode 3 is still available from Apple’s developer site. Download Xcode 3.2.6, which will require you to log in with your Apple dev credentials.

Alas, Xcode 3 doesn’t really want to be installed on Lion. No matter, its version checks can be defeated. I found out how to make it work from this link. I’ll repeat the instructions here, in case that link goes dead:

1. Mount the Xcode 3.2.6 DMG
2. Open Terminal
3. Enter these commands:

export COMMAND_LINE_INSTALL=1
open "/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg"

… then run the installation program as usual.

Partway through, the Xcode 3 installer demanded that I shut down iTunes, even though it wasn’t running. On a hunch, I used Activity Monitor to kill iTunes Helper, and that did indeed make it shut up and finish installing.

If you want to create a link to Xcode 3, the app is installed here by default:

/Developer/Applications/Xcode.app

Drag it from that location into the Dock or wherever else you’d like it to be.

After Xcode 3 is installed, you’ll want to launch it to make sure it really works. On my system, Lion declared that it needed to download a Java runtime before this was possible.

Step 2: Install Xcode 4.3.1

Apple has decided to move Xcode 4 into the Mac App Store, so you’ll have to run the App Store app to download it. It doesn’t have an installer like earlier Xcode versions, it’s just a plain old app in your /Applications folder. Start it, and it will declare that it has to install a framework first, so let it do that.

At this point, you’ve got a cosmetic problem: the Xcode 3 and Xcode 4 icons are identical. You can solve that problem by installing Jeff LaMarche’s replacement icon. He wrote that article for a much older version of Xcode 4, but the replacement worked just fine for me.

Step 3: Install the command line tools

Xcode 4 no longer installs command-line tools by default. Assuming you need them, like I do, then you should open the Xcode 4 preferences window, go to the Downloads tab, look for the item labeled “Command Line Tools,” and press the Install button. This will take just a few minutes, and the tools will be installed, inside the Xcode 4 application bundle.

The next problem you’ll discover is that, if you fire up a terminal window and type a command such as xcodebuild, you’ll get the Xcode 3 command line tools by default. That is not what I want. So the next step is to modify your .profile file, or whatever you normally use to control the PATH environment variable, and add these paths near the beginning:

/Applications/Xcode.app/Contents/Developer/Tools
/Applications/Xcode.app/Contents/Developer/usr/bin

Step 4: Device debugging

If you’re like me, you have a pile of devices you use for testing and debugging. Both Xcode 4 and Xcode 3 are able to install and debug apps on all my devices, which are running versions of iOS from 3.1 to 5.1.

The trick is to start on Xcode 4. Connect your device to the 30-pin connector, open Xcode 4, and look in the Organizer window. If this is the first time you’ve connected this device, it will ask you if you want to use it for debugging, and it may have to download some files to make that possible. Eventually, the little LED next to the device should turn green. After that, exit Xcode 4, open Xcode 3, and try it there. It looks like Xcode 3 copies some files from wherever Xcode 4 stashed them, and then it’s off to the races.

Aftermath

I’ve been using this setup for a number of months now. What I’ve discovered is that Xcode 3 is unfortunately pretty crippled when run on Lion. Debugging via GDB is impossible. Source code windows often have bogus titles applied. Various other cosmetic bugs abound. In short, Xcode 3 is not nearly as pleasant to use as it was on Snow Leopard. But it’s still better than Xcode 4, for the most part, in my opinion. So I soldier on.

And … fin

As of this writing, it is now a few months later, and I use Xcode 4 all the time. I still don’t like it, but there are way too many things that Xcode 3 can’t do anymore, and switching back and forth all the time is giving me a headache.

I did save the Xcode 3 versions of Pixie and Property List Editor, however. You can download a more recent version of Pixie from Apple’s developer site, but it’s not as good as the old one, and the icon is uglier. With Xcode 4, you’re expected to edit property lists within the IDE itself, but that’s often not very convenient. If you’re going to follow my lead, be aware that Property List Editor won’t work without PlistEdit.framework, which is installed in your /Developer folder along with all the other Xcode 3 stuff.

And with that, I am officially giving up the fight. You win, Apple. I sure wish Steve J. had been forced to use Xcode as much as I do. I bet it wouldn’t have turned out like this.

Game Center support is complete

June 24, 2011 9:38 pm

Hearts Net version 4.0.6 is now available for download on the App Store.

Game Center multiplayer games turned out to be a lot of work. While I was in there messing with the network code, I also added Bluetooth support. This is probably the most work I’ve done for any release of the game to date.

If you like to play via the intertubes, feel free to add me as a Game Center friend. My alias: allen.brunson

Incidentally, I also fixed that suspend/resume problem that some people were having.

Hearts Net and Game Center

May 3, 2011 6:03 pm

Game Center integration, and by extension, multiplayer games across the worldwide internet, is taking a lot longer than expected. For one thing, I discovered the hard way that it is impossible to test without two physical devices. I was able to test WiFi multiplayer games using only my Mac and a real iPhone, but that doesn’t work in this case. I only have one iPhone capable of using Game Center, so I had to order an iPad, which has not yet arrived. But I’m pretty close to finished now, no kidding. While I’m in there mucking with the network transport, I decided to add Bluetooth support as well, so that local multiplayer games will not require a WiFi connection.

This hasn’t worked really well in the past, but I’ll try again: Is there anybody out there who would like to help beta test? You could be the very first person to play an internet-wide game of Hearts Net.

Note that being a beta tester requires a fair amount of technical sophistication. Despite recent progress, such as TestFlight, installing beta apps is still sometimes frustrating. And if you are not able to clearly articulate how and why things are going wrong, then you won’t be of any use to me.

And now, here’s a little bonus for the three people who read my blog: promo codes for Hearts Net. For those who haven’t done so before, here are instructions for redeeming promo codes. That article is specifically about iTunes gift cards, but you can do the same thing with promo codes.

I was reluctant to give these out for a long time. But Apple recently changed their rules: people who download apps with promo codes cannot write reviews. This prevents people still upset about my neutering Hearts Solo, over a year ago, from using the codes for no reason other than leaving malicious, hateful reviews. Incredibly, there are people out there with nothing better to do than still be angry about that. For the rest of you: Bon appetit!

HXY3HN7HA479
PYWY9PEEYNLT
NAW43HALXME6
Y7F6H93MEHJX
WFKLJPYL9KRL

Hearts Net progress

March 29, 2011 2:41 am

Well, dang. Quite a few of you have emailed to let me know that I have once again reintroduced the “shy robot” bug.

Some players have reported that when the game is interrupted in some way and they come back to it, the robots won’t play anymore. Here’s a simple workaround. Press the home button, which will take you back to the iOS home screen. Then press the game’s icon to restart it. Problem solved.

This has to do with the new multitasking features found in iOS 4.0 and later, which I did not test thoroughly enough. In my defense, this bug has an entirely different root cause than the last time I had a “shy robot” problem, so this is not strictly a regression.

Thanks to the help of an intrepid beta tester, I found and fixed this bug, and also devised the workaround. I would submit a new version of the app to Apple, but I am right in the middle of futzing with the multiplayer networking code, which is at the moment completely broken. So I think I’m going to wait until I get the whole thing finished, and submit a new version at that point.

Keep those emails coming. I read all of them, and respond to most. It was because of all the emails I got that I knew about the scope of this most recent “shy robot” problem. In the few cases where I don’t respond, it’s because the author was either incoherent, rude, or both. Sorry, but the measly few bucks you spent on the game is not sufficient motivation for me to put up with abuse.

Thanks to everyone who has stuck with me for all this time. I am amazed that the game is still selling pretty well, despite being in the store for more than a year. Evidence suggests that most iOS games tend to peak early and fizzle off to nothing soon after, but that’s not the case here. It looks to me like I’ve got a lot of old-timers who have been playing my Hearts game pretty solidly for quite a few months. I’m still working on improving it, albeit slowly.

Hearts 3.1.0

February 17, 2011 1:37 am

After a week of waiting in the approval queue, Apple has finally put my new versions of Hearts Solo and Hearts Net into the store.

Alas, this is version does not yet include Game Center integration. This just fixes some graphics glitches, and updates the artwork so it doesn’t look quite so horrible on the iPhone 4’s retina display.

I had hoped to have a new high-res version of all the card face graphics, but the ones I’ve included here are just the old card graphics run through ImageMagick, which hopefully defeats the jaggies a little bit. I contacted a couple of graphics artists about drawing me a new set of cards, but they all wanted more money than I can afford for the job. If one of you enterprising readers thinks you could draw me a new card deck for, say, 600 bucks or less, I’d love to hear from you.

UIButton graphics highlighting

January 31, 2011 6:54 am

I have often tried to create a UIButton subclass to do something special, like draw a shadow, but couldn’t make it work. You can’t just override UIView’s drawRect: method and get the results you expect. My usual response to that is: Fine, I’ll make my button a subclass of UIControl, then.

That leaves the problem of how to highlight the button’s image when it is pressed. UIButton does a great job of this, drawing a black mask on top of the button’s image, ignoring any transparent pixels. I’ve been trying to figure out how to reproduce that effect for probably a year, I suspect, without success.

CoreGraphics is powerful. There’s pretty much nothing it can’t do. But it’s not exactly easy to work with. I have finally read enough of other people’s blog posts so that I can cobble together a solution. I’ve included a function below that inputs a UIImage object and outputs a new UIImage with a black mask drawn over it, exactly the same effect that UIButton uses.

UIButton highlighting

I’ve included a screen-shot from the simulator to show what the effect looks like. On the left, you’ll see an image that is similar to the icon for the Calendar program on the iPhone. Next is that same image, highlighted by UIButton. The third image is highlighted with the function shown below. The two highlighted versions are almost exactly the same. You can tell the difference with a color-dropper tool, but I doubt you could tell them apart with the naked eye.

I know I pretty much never use code from other people’s blog posts without modifying it to suit my own uses. Assuming you’re like that as well, here’s some notes that will help you understand the code better.

The alpha value for the black mask, 0.46, was chosen because it produces results nearly identical to what UIButton does. You can make that number bigger or smaller for a lighter or darker mask.

UIGraphicsBeginImageContextWithOptions() is the best function to use to begin an image context. It will get you high-resolution graphics on the iPhone 4’s “retina display.” But that function does not exist on older versions of iOS. Therefore, we test for its existence before calling it, by checking to see if its function pointer is NULL. If so, we fall back to the older method that’s been available since the earliest iOS versions. If you don’t plan to support versions of iOS earlier than 4.0, then you can omit the availability test.

There are a couple of lines of code that transform the coordinates normally used by CoreGraphics functions to those normally used by UIKit objects. Without those two lines, the black mask would be drawn upside-down. I don’t understand this business very well. I just know the function fails without them.

The secret sauce is CGContextClipToMask(). It was easy to figure out how to draw a colored mask over an existing image, but you need this extra step to prevent the mask from being drawn over transparent pixels.

UIImage* WBHighlightImage(UIImage* image) {     const CGSize  size = image.size;     const CGRect  bnds = CGRectMake(0.0, 0.0, size.width, size.height);     UIColor*      colr = nil;     UIImage*      copy = nil;     CGContextRef  ctxt = NULL;         // this is the mask color     colr = [[[UIColor alloc] initWithWhite:0 alpha:0.46] autorelease];     // begin image context     if (UIGraphicsBeginImageContextWithOptions == NULL)     {         UIGraphicsBeginImageContext(bnds.size);     }     else     {         UIGraphicsBeginImageContextWithOptions(bnds.size, FALSE, 0.0);     }     ctxt = UIGraphicsGetCurrentContext();         // transform CG* coords to UI* coords     CGContextTranslateCTM(ctxt, 0.0, bnds.size.height);     CGContextScaleCTM(ctxt, 1.0, -1.0);     // draw original image     CGContextDrawImage(ctxt, bnds, image.CGImage);         // draw highlight overlay     CGContextClipToMask(ctxt, bnds, image.CGImage);     CGContextSetFillColorWithColor(ctxt, colr.CGColor);     CGContextFillRect(ctxt, bnds);     // finish image context     copy = UIGraphicsGetImageFromCurrentImageContext();     UIGraphicsEndImageContext();         return copy; }

i’m a bad parent

September 7, 2010 11:15 pm

Hey folks! Long time no see! Sorry about my long absence. I started a new job and they are running me ragged. I work on a big complicated iPhone app during the day, so I don’t feel super inclined to work on yet another iPhone app on nights and weekends.

What makes me feel extra sucky about all this is that the money I have been making from Hearts Net has been steadily growing, despite my neglect. I’m not going to quote actual numbers, because that would sound like bragging, but. Pretty close to covering my rent every month. That’s substantial. So I feel like I owe something to you fine folks for stuffing so much money in my pockets, and I am forever planning to get a new version into the store, but I haven’t done so yet. Boy, do I suck.

I’ll tell you what I’ve been up to, though. I’ve mostly got the game updated for iPhone4. I know the current graphics look bad on a Retina Display, so I’ve fixed most of them. I don’t think I’m going to be able to update the card faces, though. I’ve explored various avenues, and I don’t see how I can get decent high-res cards without paying at least a thousand bucks. That’s steep, even given the substantial amount of money I’m making from the game. If any of you out there are graphics pros, and you can find a way to get me high-res playing card graphics for 500 bucks or less, I am all ears. Doesn’t have to be exclusive card graphics, either. If you sold them non-exclusively to somebody else first, I’m cool with that.

I have been reading about Apple’s new Game Center feature with interest. I’ve so far avoided adding across-the-internet play, because that would involve running my own server, and I don’t want to do that. It’s an ongoing expense, I would have to police the server for abuse, I would be the system administrator, and so on. But it looks like Apple is willing to do all that for me, including passing network messages between players. If that’s true, Game Center would save me a great deal of time, money, and grief, so I will be using it.

Finally, here’s a very nice video review that this guy did for my game: ThatSnazzyiPhoneGuy reviews Hearts Net. I’ve been aware of this for months. In fact, I even gave this guy a promo code for the game. But I just couldn’t watch it. My feeling is: hey, I know which parts of my game suck, I don’t need other people to tell me that. My friend Steph said it was a very positive review, but I still never got around to watching it, until tonight. She’s right, it’s very positive. The review was worth the promo code (heh).

Here’s some answers to the review. He seems to imply that you need a network connection to read the game’s help text. Not true! The HTML help files are stored locally in the app. Also, he wonders why I added the AutoPlay feature. The reason is that it makes the game a whole lot easier to test. Notice all the times he has to stop concentrating on what he’s talking about to play a card and keep the review going? Now imagine me, by myself, trying to test millions of card plays in network games.

ongoing

May 26, 2010 11:16 am

Apple just gave me a little over 500 bucks for a month of Hearts Net sales. That seems pretty good to me. Plenty good enough to keep maintaining it. It appears that the iPad version of the program has boosted sales a bit.

So, I’ll be working on new features and more devious player robots in the future. Might not be for awhile, because I recently started a new full-time job which is taking most of my time. But the game is still very much on the list of my current projects.