Hello Community, I created a score text using a custom font that I downloaded from Internet, but I have a big problem. My game starts with a simple “Play Button”, my game was running perfect until I used the custom font, because when I use the custom font in my game, the game turns laggy for a few seconds (for 10/20 seconds at the beggining ). I’m testing on an iPod 2G (iOS 4.2.1), but when I test it without the custom font (using native.systemFont) the game goes perfect. [import]uid: 81091 topic_id: 18791 reply_id: 318791[/import]
By the way, a question… Games like Angry Birds, Fruit Ninja and those Top Games use display scores with custom fonts or with images? How can I make a Fruit Ninja Display Score? [import]uid: 81091 topic_id: 18791 reply_id: 72324[/import]
Is there something about the font where it’s intensely detailed? If you continue to get lag problems it may be better to create the button as an image. [import]uid: 10903 topic_id: 18791 reply_id: 72334[/import]
A 2G running iOS4 isn’t going to be the fastest thing in the world but obviously that’s a big delay. I do have a tutorial up on Techority for doing a score using images - it’s not the best way of doing things but may be worth looking at as it could potentially be faster. (Worth a test, at least.)
peach :0 [import]uid: 52491 topic_id: 18791 reply_id: 72344[/import]
Peach, two questions:
1.How can I make that the score (from your tutorial) changes the images but… Hmm… Let me explain it like this: when the score changes from 0 to 100, I want that the score shows every number from 0 to 100, like a transition, no just change from 0 to 100, do you understand my point?
- I want that the score stays centered in the middle of the screen, how can I do it? [import]uid: 81091 topic_id: 18791 reply_id: 72531[/import]
Oh I see - my tutorial is no good for that. I’d suggest using a custom font and doing something like this - it’s very rough but just something I threw together that should help you. (It’s plug and play.)
[lua]display.setStatusBar(display.HiddenStatusBar)
local bg = display.newRect( 0, 0, 320, 480 )
local score = 27
local scoreText = display.newText(“0”, 100, 100, “Helvetica”, 18)
scoreText:setTextColor(0,0,0)
local function updateScore()
if tonumber(scoreText.text) < score then
scoreText.text = tostring(scoreText.text+1)
end
end
Runtime:addEventListener(“enterFrame”, updateScore)
local function makeScoreHigher ()
score = score + 35
end
timer.performWithDelay(2000, makeScoreHigher, 1)[/lua]
Peach
[import]uid: 52491 topic_id: 18791 reply_id: 72592[/import]
Peach, a custom font can be designed with multi-colors? I mean, for example, a custom font with different border/stroke color. [import]uid: 81091 topic_id: 18791 reply_id: 72784[/import]
True Type and Open Type fonts, if you use them to output text are going to typically be monochrome.
If you want something multi-color or with affects, you have to use something called “Bitmap fonts”.
Corona doesn’t directly support bitmap fonts, though they can be used via sprite sheets or movie clips, where you have a separate sprite or each image for each glyph you want to display.
Bitmap fonts are typically NOT scalable like regular fonts are. Since they are images, scaling them is the same as scaling any other image.
What you’re describing with having the numbers count up from the last score to the current one in animation, sounds like it could be cool, but it also sounds like it could be pretty distractive and it could be CPU intensive depending on how much work is going on.
[import]uid: 19626 topic_id: 18791 reply_id: 72787[/import]
Have you a website to download bitmap fonts? I didn’t find anything, and can you explain me how to use them like sprite sheets or movie clips? I’m using a tutorial from Peach, but I don’t know if that is what are you saying. [import]uid: 81091 topic_id: 18791 reply_id: 72824[/import]
I don’t have any code that I can share that uses bitmap fonts. But using a movie clip, you would create 10 graphics 0.png, 1.png … 9.png and then use the :play({startFrame=n. endFrame=n}) to have it draw a given digit.
Then you have to take your score and do some division to get each digit and then have a separate animation for each digit.
local scoreDigits = {}
scoreDigits[1] = movieclip.newAnim{"0.png", "1.png", "2.png"... "9.png"}
scoreDigits[1]:play({startFrame=1, endFrame-1})
scoreDigits[2] = movieclip.newAnim{"0.png", "1.png", "2.png"... "9.png"}
scoreDigits[2]:play({startFrame=1, endFrame-1})
scoreDigits[3] = movieclip.newAnim{"0.png", "1.png", "2.png"... "9.png"}
scoreDigits[3]:play({startFrame=1, endFrame-1})
scoreDigits[4] = movieclip.newAnim{"0.png", "1.png", "2.png"... "9.png"}
scoreDigits[4]:play({startFrame=1, endFrame-1})
scoreDigits[5] = movieclip.newAnim{"0.png", "1.png", "2.png"... "9.png"}
scoreDigits[5]:play({startFrame=1, endFrame-1})
of course you have to set the x and y to position them where you want them.
then do something like this:
ones = (score % 10) + 1 -- adjust to the fact that 0 is the 1st digit
scoreDigits[1]:play({startFrame=ones, endFrame=ones})
tens = math.floor(score, 10) % 10 + 1
scoreDigits[2]:play({startFrame=tens, endFrame=tens})
etc.
None of that is tested, but its the basic idea.
It’s a pain in the behind, but its how you use them.
[import]uid: 19626 topic_id: 18791 reply_id: 72837[/import]
I cannot create movie clips, I don’t know why, the terminal says that movieclip is a nil value. [import]uid: 81091 topic_id: 18791 reply_id: 73276[/import]
You will need to get a copy of movieclip.lua from the sample code folder or from the community code area and make sure to do a:
local movieclip = require(“movieclip”)
[import]uid: 19626 topic_id: 18791 reply_id: 73286[/import]
Oh! Ok, thank you. [import]uid: 81091 topic_id: 18791 reply_id: 73381[/import]