|
TUTORIALS, HINTS & TRICKS |
|
|
Here you find articles that cover frequently asked questions, as well as short tutorials, hints and tricks.
|
|
| | |
|
PERFORMANCE HINTS |
|
|
How fast is Text Candy? It's not easy to answer this question, because this heavily depends on the type of effect, how many (animated) texts you are using simultanously, how many processing power the rest of your game needs etc. What we know for sure, however, is that Text Candy for Corona is as fast as a Corona lib could be. We tried our best to performance-optimize every single line of code and performance is still our primary goal with ALL Candy tools. The final speed, however, primarily depends on Corona®'s mass handling of display objects and how wisely you are using Text Candy within your project.
Here are some hints that may help you to obtain the best possible performance while using Text Candy:
-
Keep animated char count as low as possible
For most effects, it is not neccessary to animate each individual char of a text object. Animating an entire text object at once (inMode = "ALL" / outMode = "ALL") requires less performance. Charwise animations should be used for short texts or during a short period of time only.
-
Use char delays
If you animate a text char by char by applying a transition to it, char delay is your friend. Use it to avoid too many chars being animated at once. Trying to animate too many chars at the same time could produce a performance hit on weak target devices. There is no exact limit of chars that you can animate at once, it solely depends on the aimed target device.
-
Reduce text redrawing
A text object needs to be redrawn when its text or any of its properties (like wrapWidth etc.) has been changed. If you pass a new text to a text object, Text Candy automatically verifies if it differs from the current text. If not, Text Candy won't redraw the text object. However, you should try to keep text redrawing at a minimum if you like to obtain the best possible performance for your project. Texts that are not animated and are not changed frequently do not require any noticeable performance.
-
Disable debugging
By default, Text Candy provides detailed debugging messages to let you know what's going on backstage. Once your project reaches a final stage, you should disbale debugging messages to gain performance. You can do this by calling TextFX.EnableDebug(false).
|
|
| | |
|
GOT BUILD ERRORS? |
|
|
Text Candy uses plain Corona standard API only, so it should run well on all devices supported by Corona.
If your build doesn't run on your device, it may be related to the build.settings file in the project folder. Simply edit it or replace it by another one.
You should also place the Text Candy library file within your project folder (and don't forget to change the path in the "require" line, too) to avoid any path problems.
A charset's sprite sheet (anyFontname.lua) should also placed in your project's root folder to avoid any path problems.
If you still can't get it to work you may be stumbled over a strange behaviour with the LUA string library that is shipped with Corona that converts special chars like Umlauts, Accents etc. to double-byte characters when they are passed as function parameters. This strange behaviour only happens when your modules are placed in sub-directories. Since Umlauts etc. are internally converted to double-byte characters, Text Candy believes that there are more characters specified than there actually are on the texture.
So in short:
just replace all Umlauts or Accents in your charOrder string passed with AddCharset() with characters that are not in use.
Example (before):
TextCandy.AddCharset ("FONT1", "myFont", "myFont.png", "0123456789AÄBCDEFGHIJKLMNOÖPQRSTÜVWXYZ'*@():,$.!-%+?;#/_", 10)
To make it work:
TextCandy.AddCharset ("FONT1", "myFont", "myFont.png", "0123456789AaBCDEFGHIJKLMNOoPQRSTUuVWXYZ'*@():,$.!-%+?;#/_", 10)
Or any other chars that are not in use.
Additional note:
If you are using CIDER as the programming IDE, you should also remove the lines that are automatically added on top of your code to prevent build errors:
-- REMOVE THESE LINES:
CiderRunMode = {};
CiderRunMode.runmode = true;
CiderRunMode.assertImage = true;
require "CiderDebugger";
|
|
| | |
|
CREATING YOUR OWN CHARSETS |
|
|
Creating bitmap charsets is basically very easy. There are just a few steps to do -once you are familiar with this process, a bitmap charset is done in about 10-15 minutes only (and can be reused in any of your future apps then).
-
STEP 1 - OPEN YOUR DRAWING APP
Use your favorite drawing application like Photo Shop, Paint Shop, Gimp etc. and create a new, transparent image that is big enough to hold all the chars you want to use (any size will do).
-
STEP 2 - ADD YOUR TEXT
Now place a text in there that contains all chars you want to use in your game. Choose a font size that fits your need best (depends on wether you want to create title logo chars, ingame texts, use them in an iPhone or iPad app etc...) Just make sure there is enough spacing between the chas, so you can apply a cool drop shadow, glowing effect etc. to the chars without overlapping them.
-
STEP 3 - APPLY EYE CANDY
Now apply any cool filters you like to -adding 3D bevels, shiny effects, chrome filters, apply a texture, a drop shadow, outlines, whatever your drawing application (or your creativity) is capable of.
-
STEP 4 - SAVE ALL CHARS
Now cut out each char and save it to disk as an individual image file (png). There is no need to cut them out properly because Zwoptex and TexturePacker both provide image cropping (automatically getting rid of empty space around each image). Name each char like "a.png", "b.png" etc. -as seen in the included font pack. This naming convention ensures that Zwoptex or Texturepacker place your chars in alphabetically order on the sprite sheet.
-
STEP 5 - IMPORT CHARS INTO TEXTUREPACKER OR ZWOPTEX
Now open either Zwoptex or TexturePacker (last mentioned provides a free version and is available for Windows, too) and import your chars. Enable cropping (so that any empty space around the chars is removed) and use a spacing of ~2 pixels between the single images. Also enable "sort by name", so that the chars are ordered in alphabetical order in the exported data sheet.
-
STEP 6 - EXPORT YOUR TEXTURE
Now export both, the texture that contains all the chars and the data file (sprite sheet). Place both in your project's root folder to avoid any path problems.
-
STEP 7 - LOAD YOUR CHARSET
Load the font into your application using
TextCandy.AddCharset ("myFontName", "dataFile", "fontImage.png", charOrder
Notice the "charOrder" parameter. This needs to be a string that contains all chars that you included in your charset, in the same order as they are placed in the .lua data sheet. This is to tell Text Candy where to find the chars on your texture.
A last thing to keep in mind: some chars will have a different height than others, a capitalized "A" will be higher than a "-" char, for example. To ensure that all chars are placed correctly when creating texts, use the .SetCharYOffset command (as described in the manual) after loading your charset into your app. This is neccessary for a few chars only like colon, semicolon etc.
That's it.
|
|
| | |
|
EMBEDDING CUSTOM VECTOR FONTS |
|
|
Follow this link to learn how to embed your own vector fonts using the Corona SDK:
Using a custom font
When using custom vector fonts in your app, please make sure that you a) included the correct font name in your build.settings file and b) that the font is properly installed on your machine. Vector fonts must be installed on the OS in order to show up in the simulator. Here is another topic in the Ansca forums that may help you getting started:
Embedding custom fonts
|
|
| | |
|