I have reached a milestone of sorts with Gemini. One of my goals has always been to be compatible enough with the Corona APIs to take advantage of some of the key third party Corona tools. One tool in particular that provides excellent capabilities is the Text Candy library. This library makes it really easy to create great looking text labels and text effects in Corona apps.
In the last few weeks I have made a lot of progress with Gemini and Text Candy. I was planning to write some of this up and show a demo earlier, but then X-Pressive had to go and drop a new version last week, grrrr!. Actually, version 1.0.12 provides one great new feature – it imports Glyph Designer font files directly now that Glyph designer exports to Text Candy Lua format. I have updated my code for this newest release.
Read on to see Text Candy in action on Gemini.
Glyph Designer is a simple yet powerful tool that allows you to export any font on your Mac as a texture file and a descriptor file. It lets you choose which characters you want to include and add special effects likes drop shadows. Below is an example image file (OpenGL texture) output from Glyph Designer:
And the following is the (abridged) Lua code generated for Text Candy:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
Because I have made a point of implementing the portions of the API that Text Cany requires first, it was surprisingly easy to get the basics working. Text Candy essentially works by creating sprites and display groups, which was some of the first functionality I implemented for Gemini.
I only had to modify about a dozen or so lines in Text Candy to make it work with Gemini.
Most of these were related to the fact that Gemini uses a right handed coordinate system with the y-axis pointing up, ala OpenGL, whereas in Corona the y-axis points down (with y=0 representing the top of the screen). I don’t have all of the Text Candy functionality working yet, but just getting some of the basic stuff working is pretty exciting.
Creating a font in Gemini using Text Candy is trivial. First load the Text Candy library then create a font with the data files:
These two lines create a font name
FONT1. This font can be used to create multiple labels and varying sizes, each with its own special effect. Creating a label is similarly trivial:
1 2 3 4 5 6 7 8 9 10 11 12 13
CreateText method takes a Lua table that describes the text, including its position. Adding effects to labels is also easy. The following code takes the label from above and warps it into a circle:
1 2 3 4 5 6 7 8 9
The labels created by Text Candy are Gemini display objects, so they can be manipulated like any other display object. The following code applies a transition to our circle label, causing it two go through two full rotations over a twenty second interval:
While all this is no doubt fascinating, you are probably wanting to actaully see something move at this point. The video screen capture from the iOS simulator shown below shows our spinning label, a horizontal marquee label, plus a running horse sprite thrown in for good measure.
The code for this demo is given below. I will explain the rest of it in another post.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
Hopefully this has given you some idea of the kinds of things you will be able to do with Gemini in the near future. I will continue to add support for other Text Candy effects. For now, simply being able to use Text Candy and Glyph Designer for generating labels is huge.