Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Where in my program do I render and update the player score with BMFont — Gideros Forum

Where in my program do I render and update the player score with BMFont

stoddsiestoddsie Member
edited September 2012 in General questions
Hi.

I have placed a player score in my game in the top-left corner, and added it to my onEnterFrame using:

text = BMTextField.new(font, tostring(score))
stage:addChild(text)

The score is incremented when my player collides with objects. However, the previous scores are left on the screen, and the new score is placed on top. Presumably, I am placing my score in the wrong place. Should I be creating the score in the Init function, and then just updating it in my onEnterFrame?

If anyone can suggest the best way to set up a scoring system I'd be very grateful.

Thanks

James

Comments

  • Should I be creating the score in the Init function, and then just updating it in my onEnterFrame?
    In a word - yes.
    Just call the BMFont:setText() function with your new score - however I'd only update if the value changes or else you'll be wasting a lot of time re-creating objects that don't need to be created.

    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
  • Thanks techdojo, that's great. And yes, I agree, I will wrap some logic around it that says only update the text if the value has actually changed.

    Cheers for the quick response.

    James
Sign In or Register to comment.