Archive for the ‘Mobile’ Category

Embedding OTF Fonts in Windows Phone 8

Friday, January 3rd, 2014

Now I don’t think there is a difference between between TTF and OTF fonts when it comes to Windows Dev. I do how ever think that the way the fonts them selves are set up, are different.

A lot of people as well as my self have had trouble with embedding OTF fonts. The problem ended up being the name of the font inside the font file. The Windows OS font does not show you all of the variations on the name.

How to embed a font you are having trouble with:



MyFontFileNameExtraBold.otf needs to have 2 properties set the “Build Action” which should be resource for WinPhone 8 and the “Copy to Output Directory” which should be Copy if newer. See image bellow.


The font name problem

As you can see in the above FontFamily prams for custom fonts its made up of the path to the font followed by a hash then the font name. Now for some reason it is not the font name that creates the problem. first you need a font viewer that  shows all the names.

I use:

Open up your font in this program. You will see lots of info for the font. In my case I needed to use the “Preferred Family” name to replace the “My Font Name” in the path above. but if that does not work for you try one of the others. See image bellow:


AppCode File Template for CoreGraphics and PaintCode

Wednesday, November 21st, 2012

In my last post I setup a CALayer subclass for CoreGraphics and PaintCode.

I created an AppCode template that I am sharing here.

The header file template:

Implamentation file template:


Vector Graphics in iOS with CoreGraphics and PaintCode from an SVG file

Monday, November 19th, 2012

Since I started iOS development there has always been one thing missing for me. That has been a vector graphic file format. There is no format currently natively supported by apple.

I did some digging and found SVGKit. This is a very nice library that loads in .svg files. It even supports SVG animations. Not to mention its free. So I had to share this. However it can be tricky to set up.

In the end I settled on using PaintCode. PaintCode is a vector based graphics application that generates CoreGraphics Objective-C. PaintCode will also load in SVG files.

The idea is you load an SVG file into PaintCode. Edit it if needed then copy the Objective-C code into your project.

There are different ways you can include it in your projects. I would like to use it in layer of the CALayer flavour.

What I have done is create a CALayer subclass. That all you have to do is past in the PaintCode code.

For convenience I create all my vector assets at 100×100 pixels. I then use a scale to get it to the right size.

This assumes you have PaintCode and have already got the code ready. Also assumes the image is 100×100.

Step 1:
Add the “QuartzCore.framework” to your project.

Step 2:
Create a new file using the “Objective-C Class” template for iOS. USE CALayer Subclass

Step 3:
Add the bellow line to to your Header file(.h).


Step 4:

Add the bellow code to the implementation file(.m). Note: see line 17 if your image is not 100×100 pixels

Step 5:

Add the CoreGraphics code to the drawImage method.

Step 6:

Add this layer to a view that is currently on the view stack.


Thats all you need.



I created an AppCode template for this.


Using LevelHelper without Box2d for Cocos2d-X

Thursday, November 8th, 2012

I have been trying out LevelHelper recently and it has been very useful when making games that have a fair bit of physics.

I was looking at making a really simple game that did not require physics. Thats where LevelHelper seemed to fall over. Since the editor generates code for you and that code has reference to Box2D.

Fear not for all is not lost, you can still use LevelHelper without implementing the physics. You still need use the Cocos2D-X with Box2D template in xCode. You just don’t attach the physics properties.

So follow the tutorials on the LevelHelper site. When you get to the bellow line of code in the second video:

The first parameter “world” is used to attach the physics properties. The second parameter “this” is what all the image assets in LevelHelper level are attached to. All you need to do is change the above line to:

Now just ignore any code to do with physics and Box2D.

Creating Frame Animation in Cocos2d-X 2.0 Using a Sprite Sheet

Saturday, July 28th, 2012

Since the Cocos2d-X 2.0 rc2 a lot of the initialisation has changed so this code works in Cocos2d-X 2.0.

First create a sprite sheet so we can load it in.

Once you have created the Sprite Sheet you will end up with a image file and plist.


I like to name my sprites like this:



It makes creating the animations easier. My code below is depended on the above naming convention.

Create Cocos2d-X 2.0 Sprite Sheet

Sunday, July 22nd, 2012

Cocos2dx is the C++ implementation of Cocos2d. Even though it is C++ and cross platform it still uses plists. There are probably a lot of tools out there that can help you create these sprite sheets. I am currently using SpriteHelper which has export settings specifically targeting Cocos2D-X. I used to use Texture Packer for Cocos2D because it has a nice PVR viewer.

The main reason i am using SpriteHelper is because of Level Helper. Level Helper looks like it has a lot of potential.

Windows 7 Mobile SDK

Tuesday, March 16th, 2010

Mix is upon us ons again. Microsoft has finally released the Windows 7 Mobile SDK which can be found here. There is a supporting site with information here about the new platform and some examples.

Win7 Mobile is not built on previous windows mobile platform but a clean concept. The development tools are new to mobile too. It utilises  Silverlight and XNA for application and games development. So it will start with a pretty big developer base.

I was hoping to get a peak at the new Windows Mobile OS from the emulator but all I found was the  browser. The UI and other things are there. The ability to compile and tests apps so early is also very nice put none of the rumoured integration with core apps features seem to be available yet.  You do on the other hand get to see what the feel of there user journey is like and how the menus and navs will work.

All and all worth a look.


Here is some new Blend 4 + Windows 7 Mobile plugin in for Blend


Here is some nice tutorials.

Extending(Subclassing) UIButton in Objective-C

Friday, July 10th, 2009

After playing around with UIButton class for a while I found Apple have been very sneaky with some  of their UI classes.

What it appears they have done is use the UIButton class as a sort of wrapper for a number of private button classes. “UIRoundedRectButton” is one of those classes.

“UIRoundedRectButton” is a private class so it can not be extended(subclassed). The initilizers normaly return an instance of self and if that self is not the class type trying to hold it there will be trouble. The problem is if you initialise UIButton with buttonWithType the class it returns is a private class. If you try and extended the UIButton once your custom class is initialized it returns a “UIRoundedRectButton” object which is private so you can not contain it.

If you try the code below which uses the description you can see the object description is not UIButton.

In short you can not extend UIButton and initialize it with buttonWithType  in Objective C. On the other hand you can extened UIButton for a button in interface builder. If  you use interface builder you need to use initWithCoder as the initialiser. While interface builder does the private stuff.

SWF to SIS Online

Tuesday, January 13th, 2009

Mobile development is something I have always wanted to spend some time on. Recently I have been looking at mobile application development. I have found there are a lot applications or tutorials on how to convert your Flash Lite files to sis installers which allow you present your swf files like an application on the main menu of your Symbian based phone.

SWFPack is a on-line service which will package up your swf into sis file with little to no effort. Mind you its still in beta but it does what it promises on the tin. Hell it even lets you add a custom icon which is used on the menu.