Bitmap Fonts in Cocos2d-x

This article describes the process of creating a bitmap'd font, using the GIMP image editor, the image-magick suite, and some home-brewed C-code. It also describes how to use the font in the Cocos2d-x/Android-Studio development environment.

For this project you will need:

  • Bash (Sorry, moved from MSWindows to Ubuntu and have never looked back - script might be translatable to MSDOS),
  • GIMP image editor (for creating the bitmap font strip),
  • Image-magick suite (splits font strip from Gimp into individual images),
  • A C++ compiler (g++, or clang are good - for compiling my code snippet),
  • TexturePacker (free version, to glue all letters into sprite sheet),
  • A Cocos2d-x project (to include your sprite-sheet into a game/app), and,
  • the Android Studio IDE (to compile the Cocos2d-x project).

I actually wrote this post some time ago but since then my OS has had to be re-imaged and surprise, surprise, that's where MySQL saves its database - fortunately my development environment was all on the /home partition. I've, in the interim, learned how to move my MySQL database to a safe location so hopefully that won't happen again. I've also gotten smarter and installed a WordPress plugin to back my system up off-site (including the MySQL database).

Now, if I can remember what I wrote before...

Let me know how this works for you. I'll try to help if you are having problems, time permitting.

If you have a bitmap font of which you are particularly proud let me know and I will link it on the example post above. Good luck!

Fortran Translator Progress

After typing up my intro page for my idea of a Fortran2C translator and reading some of the documentation I mentioned I was chomping at the bit to try it out to see how far I could get. Well I've had some progress already!

Creating the front-end actually worked out easier than I was expecting. BNFC isn't perfect but, once you get used to it's quirks and adjust for it's shortcomings, it is a real boon to creating a language front-end. Mind you it still requires some fore-knowledge of the workings and use of Flex/Bison (or lex/yacc). What follows is my progress in the creation of a Fortran to C translator. I'll update this list as I get parts of the translator working:

Cocos2d-x Programming

I'm fairly new to Cocos2d-x programming. This forced me spend some time pondering things that haven't seemed quite as easy as I would have expected. Therefore, I thought I'd share what I've learned in a series of posts.

There are also a number of very valuable posts in Chinese which I hope to bring to English. I need to scout these out and talk to their authors first but hopefully they will willing to have me translate them.

I've got code for most of the following topics which I will post as time permits. If there is a particular topic that interests you, or if a post needs clarification or correction, more let me know and I'll get to that sooner

A few things to understand about a Cocos2d-x program:

  • Cocos2d-x Scene Graph - The structure of a Cocos2d-x program,
  • Cocos2d-x Interface with Android - How is Cocos2d-x started,
  • Cocos2d-x Talking to Android - How to use Android services not coded in t Cocos2d-x,
  • Cocos2d-x AppDelegate - Starting up the Cocos2d-x program,
  • Cocos2d-x Talking to Linux Kernel - Socket programming,
  • Cocos2d-x Scene Hierarchy - Which objects can be used as scene root.

Some UI (User Interface) stuff:

  • Cocos2d-x UITextBMFont - Display a fast bit-map font (see below on how to create bit-mapped fonts for your own program,
  • Cocos2d-x UIWebView - Display a webpage within your scenes,
  • Cocos2d-x UIVideoPlayer - Display a video within a scene,
  • Cocos2d-x UITextField -
  • Cocos2d-x UITextAtlas -
  • Cocos2d-x UIText -
  • Cocos2d-x UISlider - Add a slider control to your form, with graduations,
  • Cocos2d-x UIScrollView -
  • Cocos2d-x UIRichText - Display font text with attributes,
  • Cocos2d-x UILoadingBar - Display a progress bar,
  • Cocos2d-x UIListView - Display a drop-down type list,
  • Cocos2d-x UILayout -
  • Cocos2d-x UIImageView - Display an image,
  • Cocos2d-x UIEditBox - Get text input from user,
  • Cocos2d-x UICheckBox - Setting up a checkbox.

Scheduling Functions:

  • Cocos2d-x Schedule Update - Asynchronous function calls to off-load GUI task and to use timing services,
  • Cocos2d-x Schedule Update - Calls the update function every frame,
  • Cocos2d-x Schedule a function once - One shot function call,
  • Cocos2d-x Schedule a function a set number of times with a set time gap between calls with an initial delay,
  • Cocos2d-x Schedule a function forever - With a set time gap between calls,
  • Cocos2d-x Schedule a custom function - To run every frame,
  • Cocos2d-x Unscheduling - Scheduled functions can be stopped very easily.

Miscellaneous Stuff:

  • Cocos2d-x Hello World - A better starting place,
  • Cocos2d-x PLIST - Reading of PLIST file from Resources, and Reading/Writing from/to Device memory,
  • Cocos2d-x Audio services both for effects and background music,
  • Cocos2d-x Accelerometer Input - Detect when the user has interacted with their device by tilting it,
  • Cocos2d-x Keyboard Input - detect when the user has interacted with their device using a keyboard,
  • Cocos2d-x Mouse Input - Detect when the user has interacted with their device using a mouse,
  • Cocos2d-x Single Touch Input - detect when the user has interacted with their device using touch primarily for mobile devices using a single finger,
  • Cocos2d-x Multi Touch Input - Detect when the user has interacted with their device using touch primarily for mobile devices using a multiple fingers,
  • Cocos2d-x Open URL - Opening up a web page from your Android app,
  • Cocos2d-x Clipping Node - Using a stencil object,
  • Cocos2d-x PageView - Scrolling pages,
  • Cocos2d-x Scene Transitions - The functions: pushScene, popScene, popToRootScene, popToSceneStackLevel,
  • Cocos2d-x Scene Transitions - Doing a scene transition with a transition effect, both push and pop.